/* ==================== CSS VARIABLES ==================== */
:root {
    color-scheme: light dark;
    
    /* System Colors (iOS-inspired) */
    --systemBlue: rgb(0, 122, 255);
    --systemGreen: rgb(52, 199, 89);
    --systemPurple: rgb(175, 82, 222);
    --systemOrange: rgb(255, 149, 0);
    --systemPink: rgb(255, 45, 85);
    --systemIndigo: rgb(88, 86, 214);
    --systemTeal: rgb(90, 200, 250);
    --systemRed: rgb(255, 59, 48);
    
    /* Text Colors */
    --text-primary: #050505;
    --text-secondary: rgba(5, 5, 5, 0.72);
    --text-tertiary: rgba(5, 5, 5, 0.5);
    --text-quaternary: rgba(5, 5, 5, 0.12);
    
    /* Surfaces */
    --surface-bg: #f5f7fb;
    --surface-bg-rgb: 245, 247, 251;
    --card-bg: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --overlay-bg: rgba(0, 0, 0, 0.4);
    
    /* Border Radius */
    --radius-xl: 32px;
    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 10px;
    
    /* Shadows */
    --shadow-soft: 0 30px 80px rgba(15, 23, 42, 0.18);
    --shadow-card: 0 18px 45px rgba(15, 23, 42, 0.12);
    --shadow-hover: 0 24px 60px rgba(15, 23, 42, 0.2);
    
    /* Typography */
    --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    
    /* Z-index layers */
    --z-modal: 9999;
    --z-menu: 8000;
    --z-overlay: 7999;
    --z-progress: 1001;
    --z-toggle: 1002;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f8fbff;
        --text-secondary: rgba(248, 251, 255, 0.72);
        --text-tertiary: rgba(248, 251, 255, 0.45);
        --text-quaternary: rgba(248, 251, 255, 0.2);
        --surface-bg: #05060f;
        --surface-bg-rgb: 5, 6, 15;
        --card-bg: #0f172a;
        --glass-bg: rgba(15, 23, 42, 0.7);
        --overlay-bg: rgba(0, 0, 0, 0.7);
        --shadow-soft: 0 40px 80px rgba(0, 0, 0, 0.65);
        --shadow-card: 0 24px 54px rgba(0, 0, 0, 0.6);
        --shadow-hover: 0 32px 72px rgba(0, 0, 0, 0.75);
    }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInFromLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.05); }
}

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

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

/* ==================== HERO WATERMARK ==================== */
.content-hero {
    position: relative;
    overflow: hidden;
}

.hero-watermark-wrapper {
    position: absolute !important;
    top: 20px !important;
    right: 40px !important;
    text-align: right;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}

.hero-watermark-chapter {
    font-size: clamp(60px, 8vw, 100px);
    font-weight: 900;
    font-family: Georgia, 'Times New Roman', serif;
    color: rgba(255, 255, 255, 0.15);
    line-height: 1;
    letter-spacing: -0.02em;
    text-shadow: 0 0 60px rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    margin-bottom: 4px;
}

.hero-watermark-lesson {
    font-size: clamp(40px, 5vw, 70px);
    font-weight: 700;
    font-family: Georgia, 'Times New Roman', serif;
    color: rgba(255, 255, 255, 0.10);
    line-height: 1;
    letter-spacing: -0.01em;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

/* Dark mode - slightly more visible */
@media (prefers-color-scheme: dark) {
    .hero-watermark-chapter {
        color: rgba(255, 255, 255, 0.08);
    }
    .hero-watermark-lesson {
        color: rgba(255, 255, 255, 0.05);
    }
}

/* Ensure content stays above watermark */
.hero-content {
    position: relative;
    z-index: 1;
}

/* Responsive - scale watermark on small screens */
@media (max-width: 768px) {
    .hero-watermark-wrapper {
        right: 20px;
        opacity: 0.7;
    }
    .hero-watermark-chapter {
        font-size: 50px;
    }
    .hero-watermark-lesson {
        font-size: 32px;
    }
}

@keyframes bounceRight {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(20px); }
}

@keyframes bounceLeft {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-20px); }
}

/* ==================== BASE STYLES ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-system);
    background: var(--surface-bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100%;
    overflow: hidden;
    touch-action: none;
}

/* ==================== SKIP LINK ==================== */
.skip-link {
    position: fixed;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--systemBlue);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    z-index: 10001;
    font-weight: 600;
    transition: top 0.3s ease;
    text-decoration: none;
}

.skip-link:focus {
    top: 20px;
    outline: 2px solid white;
    outline-offset: 2px;
}

/* ==================== PROGRESS BAR ==================== */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--text-quaternary);
    z-index: var(--z-progress);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--systemBlue), var(--systemPurple));
    transition: width 0.3s ease;
    width: 0%;
}

/* ==================== SCREEN READER ONLY ==================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==================== PRIMARY HEADING CONTAINER ==================== */
.sticky-header {
    position: fixed;
    top: 4px;
    left: 0;
    right: 0;
    z-index: var(--z-toggle);
    background: rgba(var(--surface-bg-rgb), 0.5);
    backdrop-filter: blur(20px) saturate(180%);
    padding: 12px 16px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--text-quaternary);
    box-shadow: none;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s ease;
}

/* Hamburger Menu Button (inside header) */
.sticky-header .menu-toggle {
    position: relative;
    top: auto;
    left: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--text-quaternary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.sticky-header .menu-toggle:hover {
    background: var(--surface-bg);
    transform: scale(1.05);
}

.sticky-header .menu-toggle:active {
    transform: scale(0.95);
}

.hamburger-icon {
    width: 20px;
    height: 16px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger-icon span {
    display: block;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle.active .hamburger-icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.active .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .hamburger-icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ==================== SIDE MENU ==================== */
.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 360px;
    background: var(--card-bg);
    z-index: var(--z-menu);
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: var(--shadow-soft);
}

.side-menu.active {
    transform: translateX(0);
}

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px;
    border-bottom: 1px solid var(--text-quaternary);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
    backdrop-filter: blur(20px);
}

.menu-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.3rem;
}

.brand-icon {
    font-size: 1.6rem;
}

.brand-text {
    background: linear-gradient(135deg, var(--systemBlue), var(--systemPurple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--text-quaternary);
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.menu-close:hover {
    background: var(--text-tertiary);
    transform: scale(1.05);
}

.menu-search {
    padding: 16px 20px;
    border-bottom: 1px solid var(--text-quaternary);
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--text-quaternary);
    background: var(--surface-bg);
    color: var(--text-primary);
    font-family: var(--font-system);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--systemBlue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.menu-content {
    padding: 20px;
}

.menu-section {
    margin-bottom: 32px;
}

.menu-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding: 0 12px;
}

.menu-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-item {
    padding: 14px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    font-family: var(--font-system);
    font-size: 0.95rem;
}

.menu-item:hover {
    background: var(--surface-bg);
    transform: translateX(4px);
}

.menu-item.active {
    background: rgba(0, 122, 255, 0.12);
    color: var(--systemBlue);
    font-weight: 600;
}

.menu-item-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.menu-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Menu Backdrop */
.menu-backdrop {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(8px);
    z-index: var(--z-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.menu-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* ==================== CARDS CONTAINER (SCROLL SNAP) ==================== */
.cards-container {
    height: 100vh;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.cards-container::-webkit-scrollbar {
    display: none;
}

.cards-container.at-start {
    animation: bounceRight 0.3s ease;
}

.cards-container.at-end {
    animation: bounceLeft 0.3s ease;
}

/* ==================== CARD STYLES ==================== */
.card {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100vh;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    overflow-y: auto;
    padding: 80px 20px 120px;
    position: relative;
}

.sticky-header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right Controls Group */
.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Progress Counter (inside header) */
.sticky-header .progress-counter {
    position: relative;
    top: auto;
    right: auto;
    background: transparent;
    backdrop-filter: none;
    border: 1px solid var(--text-quaternary);
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: none;
    color: var(--text-primary);
}

.card-content {
    max-width: 680px;
    margin: 0 auto;
    animation: fadeInUp 0.6s ease;
}

/* ==================== HERO SECTION ==================== */
.content-hero {
    position: relative;
    padding: clamp(40px, 8vw, 80px) clamp(20px, 4vw, 40px);
    color: #fff;
    border-radius: var(--radius-xl);
    margin-bottom: 32px;
    overflow: hidden;
    isolation: isolate;
}

.content-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('data:image/svg+xml,%3Csvg width="600" height="600" xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="none" stroke="rgba(255,255,255,0.08)" stroke-width="1.5"%3E%3Ccircle cx="300" cy="300" r="250"/%3E%3Ccircle cx="300" cy="300" r="180"/%3E%3Ccircle cx="300" cy="300" r="110"/%3E%3Cpath d="M150 300h300M300 150v300"/%3E%3C/g%3E%3C/svg%3E') center/contain no-repeat;
    opacity: 0.6;
    mix-blend-mode: screen;
    pointer-events: none;
}

.hero-lecture {
    background:
        radial-gradient(circle at 15% 25%, rgba(175, 82, 222, 0.65), transparent 55%),
        radial-gradient(circle at 85% 15%, rgba(52, 199, 89, 0.5), transparent 50%),
        linear-gradient(125deg, #1a0b2e, #2d1b69 45%, #5b21b6 70%, #7c3aed);
}

.hero-problem {
    background:
        radial-gradient(circle at 25% 40%, rgba(0, 122, 255, 0.5), transparent 40%),
        radial-gradient(circle at 75% 40%, rgba(175, 82, 222, 0.45), transparent 40%),
        linear-gradient(125deg, #1e3a8a, #3730a3 50%, #6b21a8 80%, #9333ea);
}

.hero-content {
    position: relative;
    z-index: 10;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(16px);
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.hero-title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
}

/* ==================== SECTION DIVIDERS ==================== */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 32px 0 24px 0;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.08), rgba(175, 82, 222, 0.08));
    border-radius: var(--radius-md);
    border-left: 4px solid var(--systemBlue);
}

.section-divider-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.section-divider-text {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--systemBlue), var(--systemPurple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Analysis Card - Beautiful gradient card before solution steps */
.analysis-card {
    margin: 24px 0 32px 0;
    padding: 28px 24px;
    background: linear-gradient(135deg, 
        rgba(0, 122, 255, 0.9) 0%, 
        rgba(175, 82, 222, 0.9) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(175, 82, 222, 0.25);
    position: relative;
    overflow: hidden;
}

.analysis-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.analysis-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3), 
        rgba(255, 255, 255, 0) 50%, 
        rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-lg);
    z-index: -1;
}

.analysis-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.analysis-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

.analysis-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.analysis-content {
    font-size: 1rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Final Answer Card - Beautiful blue gradient card */
.final-answer-card {
    margin: 24px 0;
    padding: 28px 24px;
    background: linear-gradient(135deg, 
        rgba(0, 122, 255, 0.85) 0%, 
        rgba(90, 200, 250, 0.85) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.final-answer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.final-answer-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3), 
        rgba(255, 255, 255, 0) 50%, 
        rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-lg);
    z-index: -1;
}

.final-answer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.final-answer-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

.final-answer-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.final-answer-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Explanation Card - Beautiful purple gradient card */
.explanation-card {
    margin: 24px 0;
    padding: 28px 24px;
    background: linear-gradient(135deg, 
        rgba(175, 82, 222, 0.85) 0%, 
        rgba(88, 86, 214, 0.85) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(88, 86, 214, 0.25);
    position: relative;
    overflow: hidden;
}

.explanation-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.explanation-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3), 
        rgba(255, 255, 255, 0) 50%, 
        rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-lg);
    z-index: -1;
}

.explanation-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.explanation-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

.explanation-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.explanation-content {
    font-size: 1rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Knowledge Card - Beautiful orange gradient card */
.knowledge-card {
    margin: 24px 0;
    padding: 28px 24px;
    background: linear-gradient(135deg, 
        rgba(255, 149, 0, 0.85) 0%, 
        rgba(255, 204, 0, 0.85) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(255, 149, 0, 0.25);
    position: relative;
    overflow: hidden;
}

.knowledge-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.knowledge-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3), 
        rgba(255, 255, 255, 0) 50%, 
        rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-lg);
    z-index: -1;
}

.knowledge-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.knowledge-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

.knowledge-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.knowledge-content {
    font-size: 1rem;
    line-height: 1.7;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.knowledge-content ul li {
    margin-bottom: 8px;
}

/* Objectives Card - Beautiful green gradient card */
.objectives-card {
    margin: 24px 0;
    padding: 28px 24px;
    background: linear-gradient(135deg, 
        rgba(52, 199, 89, 0.85) 0%, 
        rgba(48, 176, 199, 0.85) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(52, 199, 89, 0.25);
    position: relative;
    overflow: hidden;
}

.objectives-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.objectives-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3), 
        rgba(255, 255, 255, 0) 50%, 
        rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-lg);
    z-index: -1;
}

.objectives-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.objectives-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

.objectives-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.objectives-content {
    font-size: 1rem;
    line-height: 1.7;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.objectives-content ul li {
    margin-bottom: 8px;
}

/* Lecture Section Card - Big gradient card for each main section */
.lecture-section-card {
    margin: 32px 0;
    padding: 28px 24px;
    background: linear-gradient(135deg, 
        rgba(88, 86, 214, 0.85) 0%, 
        rgba(175, 82, 222, 0.85) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(88, 86, 214, 0.25);
    position: relative;
    overflow: hidden;
}

.lecture-section-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.lecture-section-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3), 
        rgba(255, 255, 255, 0) 50%, 
        rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-lg);
    z-index: -1;
}

.lecture-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.lecture-section-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

.lecture-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.lecture-section-content {
    position: relative;
    z-index: 1;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.lecture-section-content p {
    line-height: 1.7;
}

/* Common Mistakes Card - Beautiful red-orange gradient card */
.common-mistakes-card {
    margin: 24px 0;
    padding: 28px 24px;
    background: linear-gradient(135deg, 
        rgba(255, 59, 48, 0.85) 0%, 
        rgba(255, 149, 0, 0.85) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(255, 59, 48, 0.25);
    position: relative;
    overflow: hidden;
}

.common-mistakes-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.common-mistakes-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3), 
        rgba(255, 255, 255, 0) 50%, 
        rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-lg);
    z-index: -1;
}

.common-mistakes-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.common-mistakes-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

.common-mistakes-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.common-mistakes-content {
    font-size: 1rem;
    line-height: 1.7;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.common-mistakes-content ul li {
    margin-bottom: 8px;
}

/* Learning Tips Card - Beautiful teal-green gradient card */
.learning-tips-card {
    margin: 24px 0;
    padding: 28px 24px;
    background: linear-gradient(135deg, 
        rgba(90, 200, 250, 0.85) 0%, 
        rgba(52, 199, 89, 0.85) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(90, 200, 250, 0.25);
    position: relative;
    overflow: hidden;
}

.learning-tips-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.learning-tips-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3), 
        rgba(255, 255, 255, 0) 50%, 
        rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-lg);
    z-index: -1;
}

.learning-tips-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.learning-tips-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

.learning-tips-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.learning-tips-content {
    font-size: 1rem;
    line-height: 1.7;
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.learning-tips-content ul li {
    margin-bottom: 8px;
}

.solution-steps-section {
    margin-top: 32px;
}

/* Timeline Steps Design - Beautiful step-by-step layout */
.step-timeline-item {
    display: flex;
    gap: 20px;
    padding: 24px 0;
    position: relative;
}

.step-timeline-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 55px;
    top: 68px;
    bottom: -24px;
    width: 2px;
    background: linear-gradient(180deg, var(--systemBlue), transparent);
    opacity: 0.3;
}

.step-badge {
    min-width: 110px;
    height: 48px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--systemBlue), var(--systemPurple));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    position: relative;
    z-index: 1;
    padding: 0 24px;
    box-sizing: border-box;
}

.step-number {
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'SF Pro Display', -apple-system, sans-serif;
    white-space: nowrap;
    letter-spacing: 0.3px;
    text-align: center;
    width: 100%;
}

.step-content-wrapper {
    flex: 1;
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.step-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.step-analysis {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.step-answer {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.08), rgba(48, 176, 199, 0.08));
    border-radius: var(--radius-md);
    margin: 16px 0;
    border-left: 3px solid var(--systemGreen);
}

.answer-check {
    color: var(--systemGreen);
    font-size: 1.3rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ==================== SECTION CARD ==================== */
.section-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: clamp(24px, 4vw, 40px);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--text-quaternary);
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    margin-bottom: 16px;
    color: var(--text-primary);
}

.section-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

/* ==================== SUBSECTION STYLES ==================== */
.subsection {
    margin-bottom: 32px;
    margin-top: 24px;
}

.subsection-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.subsection-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.type-definition .subsection-icon {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.type-formula .subsection-icon {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.type-example .subsection-icon {
    background: linear-gradient(135deg, #10b981, #059669);
}

.type-note .subsection-icon {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.subsection-title h3 {
    font-size: 1.15rem;
    margin-bottom: 4px;
}

.subsection-type {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.subsection-content {
    background: transparent;
    border-radius: var(--radius-md);
    padding: 0;
    border-left: none;
    line-height: 1.7;
    font-size: 1.05rem;
    color: var(--text-primary);
    font-family: var(--font-system);
}

/* ==================== FIGURE GALLERY ==================== */
.figures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 24px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: var(--radius-md);
}

.figure-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.figure-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: all 0.3s ease;
    background: var(--card-bg);
    border: 1px solid var(--text-quaternary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
}

.figure-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.figure-item img {
    max-width: 100%;
    max-height: 400px;
    height: auto;
    display: block;
    object-fit: contain;
}

/* ==================== INFO BOXES ==================== */
.info-box {
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin: 20px 0;
    border-left: 4px solid;
}

.info-box h4 {
    font-size: 1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-box ul {
    list-style: none;
    padding: 0;
}

.info-box li {
    padding-left: 24px;
    position: relative;
    margin-bottom: 8px;
    line-height: 1.6;
}

.info-box li::before {
    position: absolute;
    left: 0;
    font-weight: bold;
}

.key-points {
    background: rgba(52, 199, 89, 0.08);
    border-left-color: var(--systemGreen);
}

.key-points li::before {
    content: '✓';
    color: var(--systemGreen);
}

.common-mistakes {
    background: rgba(255, 45, 85, 0.08);
    border-left-color: var(--systemPink);
}

.common-mistakes li::before {
    content: '⚠';
    color: var(--systemPink);
}

.learning-tips {
    background: rgba(255, 149, 0, 0.08);
    border-left-color: var(--systemOrange);
}

.learning-tips li::before {
    content: '💡';
    color: var(--systemOrange);
}

/* ==================== FIGURE MODAL ==================== */
.figure-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
}

.figure-modal.active {
    display: block;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    cursor: pointer;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    margin: 5vh auto;
    animation: fadeInUp 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-close {
    position: absolute;
    top: -48px;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-image {
    max-width: 100%;
    max-height: calc(90vh - 80px); /* Reserve space for caption + margins */
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    flex-shrink: 0;
}

.modal-caption {
    margin-top: 16px;
    padding: 0 20px;
    text-align: center;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    max-width: 90vw;
    word-wrap: break-word;
    flex-shrink: 0;
}

/* ==================== LOADING SCREEN ==================== */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--surface-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--text-quaternary);
    border-top-color: var(--systemBlue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (min-width: 769px) {
    .card {
        padding: 100px 40px 140px;
    }
    
    .card::before {
        height: 160px;
    }
    
    .sticky-header {
        left: 0;
        right: 0;
        padding: 14px 24px;
    }
    
    .sticky-header .menu-toggle {
        width: 44px;
        height: 44px;
    }
    
    .sticky-header-title {
        font-size: 1.1rem;
    }
    
    .sticky-header .progress-counter {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    
    .dots-indicator {
        bottom: 40px;
        gap: 14px;
    }
    
    .dot {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 480px) {
    .content-hero {
        padding: 32px 20px;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
    
    .section-card {
        padding: 20px;
    }
    
    .step-card {
        padding-left: 52px;
    }
    
    .step-number {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

/* ==================== BOOKMARK BUTTON ==================== */
.bookmark-btn {
    position: relative;
    background: transparent;
    border: 1px solid var(--text-quaternary);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.bookmark-btn:hover,
.bookmark-btn.active {
    opacity: 1;
    transform: scale(1.1);
    background: var(--surface-bg);
}

.bookmark-btn:focus {
    outline: 2px solid var(--systemBlue);
    outline-offset: 2px;
    opacity: 1;
}

.bookmark-btn .bookmark-icon {
    display: block;
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
    display: none !important;
}

.no-scroll {
    overflow: hidden !important;
}

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
