* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Comic Sans MS', 'Nunito', 'Segoe UI', sans-serif;
}

body {
    background: #E0F7FA;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: row;
    height: 100vh;
}

/* ============ 侧边栏 ============ */
.sidebar {
    width: 240px;
    background: #FFD54F;
    border-right: 4px solid #FFCA28;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    z-index: 10;
    border-top-right-radius: 30px;
    box-shadow: 4px 0 15px rgba(0,0,0,0.05);
    height: calc(100vh - 100px);
}

.logo {
    text-align: center;
    margin-bottom: 20px;
    background: white;
    padding: 15px 10px;
    border-radius: 20px;
    border: 3px solid #FFC107;
    box-shadow: 0 4px 0 #FFC107;
    flex-shrink: 0;
}

.logo h1 { font-size: 20px; color: #FF6F00; }
.logo p { font-size: 12px; color: #FFA000; font-weight: bold; }

.category-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-bottom: 20px;
    padding-right: 5px;
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    color: #555;
    border: 3px solid transparent;
    padding: 12px 15px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
    font-weight: bold;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.category-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(0,0,0,0.1); }
.category-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.1); }
.category-btn.active { background: #4FC3F7; color: white; border-color: #03A9F4; box-shadow: 0 4px 0 #03A9F4; }
.category-btn .icon { 
    font-size: 20px; 
    width: 24px;     /* 新增：固定宽度 */
    height: 24px;    /* 新增：固定高度 */
    display: flex; 
    align-items: center; 
    justify-content: center; 
    flex-shrink: 0;  /* 防止图标被挤压 */
}

/* ============ 主内容区 ============ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    overflow: hidden;
}

.header {
    background: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #E1F5FE;
    flex-shrink: 0;
    gap: 20px;
}

.header-left {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
}

.header h2 { font-size: 24px; color: #0277BD; font-weight: 800; }
.header-stats { font-size: 13px; color: #81D4FA; font-weight: bold; margin-top: 5px; }

/* === 新增：搜索框样式 === */
.search-container {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-container input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 3px solid #E1F5FE;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
    background: #F5F5F5;
    color: #333;
    font-weight: bold;
}

.search-container input:focus {
    border-color: #4FC3F7;
    background: white;
    box-shadow: 0 4px 10px rgba(3, 169, 244, 0.15);
}

.search-container::before {
    content: '🔍';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    pointer-events: none;
}

.mascot { font-size: 35px; animation: bounce 2s infinite; flex-shrink: 0; }
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ============ 二级分类 Tabs ============ */
.sub-category-container {
    background: white;
    padding: 12px 30px;
    border-bottom: 3px solid #E1F5FE;
    flex-shrink: 0;
}

.sub-category-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.sub-category-btn {
    background: #F5F5F5;
    border: 2px solid #E0E0E0;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    color: #757575;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.sub-category-btn.active { background: #81C784; color: white; border-color: #4CAF50; box-shadow: 0 3px 0 #4CAF50; }

/* ============ 课程列表 ============ */
.playlist-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
    -webkit-overflow-scrolling: touch;
}

.playlist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.lesson-card {
    background: white;
    border-radius: 16px;
    padding: 10px;
    cursor: pointer;
    border: 3px solid #E1F5FE;
    box-shadow: 0 4px 0 #B3E5FC;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.lesson-card:hover { transform: translateY(-3px); box-shadow: 0 7px 0 #B3E5FC; }
.lesson-card:active { transform: translateY(2px); box-shadow: 0 2px 0 #B3E5FC; }
.lesson-card.playing { background: #FFF9C4; border-color: #FBC02D; box-shadow: 0 4px 0 #FBC02D; }

.lesson-card-cover {
    width: 100%;
    height: 80px;
    background: #E1F5FE;
    border-radius: 10px;
	overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin-bottom: 10px;
}

.lesson-card.playing .lesson-card-cover { background: #FFF59D; }
.lesson-card-cover.animated { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

.lesson-card-title {
    font-weight: 900;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
	word-break: break-all;
}

.lesson-card-author { font-size: 11px; color: #888; font-weight: bold; }
.lesson-card-duration { margin-top: 6px; background: #F5F5F5; padding: 3px 8px; border-radius: 8px; font-size: 11px; color: #999; font-weight: bold; }

/* ============ 播放器底部 ============ */
.player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: white;
    padding: 10px 30px;
    border-top: 4px solid #4FC3F7;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-info { display: flex; align-items: center; gap: 12px; overflow: hidden; width: 25%; min-width: 180px; }
.lesson-cover { width: 50px; height: 50px; background: #FFECB3; border: 2px solid #FFC107; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.lesson-details h3 { font-size: 14px; color: #0277BD; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.lesson-details p { font-size: 11px; color: #757575; }
.lesson-time { font-size: 11px; color: #999; font-weight: bold; }

.progress-container { flex: 1; margin: 0 20px; display: flex; align-items: center; }
.progress-bar { width: 100%; height: 10px; -webkit-appearance: none; background: #E1F5FE; border-radius: 10px; outline: none; border: 2px solid #B3E5FC; }
.progress-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; background: #FFCA28; border-radius: 50%; border: 3px solid white; box-shadow: 0 2px 5px rgba(0,0,0,0.2); cursor: pointer; }

.player-controls { display: flex; align-items: center; gap: 12px; width: 35%; justify-content: flex-end; min-width: 280px; }
.control-btn { background: white; border: 2px solid #E0E0E0; font-size: 16px; cursor: pointer; width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 3px 0 #E0E0E0; transition: all 0.1s; display: flex; justify-content: center; align-items: center;}
.control-btn:active { transform: translateY(3px); box-shadow: 0 0 0 #E0E0E0; }
.control-btn.play-pause { background: #4CAF50; border-color: #388E3C; color: white; width: 50px; height: 50px; font-size: 24px; box-shadow: 0 4px 0 #388E3C; }
.control-btn.play-pause:active { transform: translateY(4px); box-shadow: 0 0 0 #388E3C; }

.volume-control { display: flex; align-items: center; gap: 5px; background: #F5F5F5; padding: 4px 8px; border-radius: 12px; }
.volume-bar { width: 50px; height: 6px; -webkit-appearance: none; background: #E0E0E0; border-radius: 3px; }
.volume-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; background: #9E9E9E; border-radius: 50%; cursor: pointer; }
#volume-percent { font-size: 11px; font-weight: bold; color: #757575; }

.mode-btn.repeat-one { background: #FFECB3; border-color: #FFC107; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #B3E5FC; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #81D4FA; }

/* ============ 可爱加载动画 ============ */
.loader-container {
    grid-column: 1 / -1; /* 保证在网格布局中独占一行，居中显示 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
}

.loader-icon {
    font-size: 50px;
    /* 弹跳动画 */
    animation: loadingBounce 0.6s infinite alternate cubic-bezier(0.2, 0.8, 0.2, 1);
}

.loader-shadow {
    width: 40px;
    height: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    margin-top: 5px;
    /* 阴影缩放动画跟随弹跳 */
    animation: shadowScale 0.6s infinite alternate cubic-bezier(0.2, 0.8, 0.2, 1);
}

.loader-text {
    margin-top: 20px;
    font-size: 16px;
    font-weight: 900;
    color: #03A9F4;
    letter-spacing: 2px;
    /* 文字呼吸灯效果 */
    animation: pulseText 1.5s infinite ease-in-out;
}

/* 动画关键帧 */
@keyframes loadingBounce {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-30px) rotate(10deg); }
}

@keyframes shadowScale {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(0.4); opacity: 0.2; }
}

@keyframes pulseText {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.98); }
}

/* ============ 错误提示可爱样式 ============ */
.error-container {
    grid-column: 1 / -1; /* 保证在网格布局中居中独占一行 */
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #FFF0F2; /* 浅粉色背景 */
    border: 3px dashed #FF8A80; /* 红色虚线边框 */
    border-radius: 20px;
    padding: 40px 20px;
    margin: 20px;
    text-align: center;
    box-shadow: 0 6px 0 #FFCDD2;
}

.error-icon {
    font-size: 60px;
    margin-bottom: 10px;
    /* 左右摇晃动画 */
    animation: shake 0.5s ease-in-out infinite alternate;
}

.error-title {
    color: #D32F2F;
    font-size: 20px;
    font-weight: 900;
    margin-bottom: 20px;
}

.error-tips {
    background: white;
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #FFCDD2;
    text-align: left;
    color: #555;
    font-size: 14px;
    max-width: 450px;
    width: 100%;
}

.error-tips p {
    color: #C62828;
    margin-bottom: 10px;
    font-size: 15px;
}

.error-tips ul {
    list-style: none; /* 去掉默认圆点 */
    padding: 0;
}

.error-tips li {
    margin-bottom: 10px;
    position: relative;
    padding-left: 25px;
    line-height: 1.6;
}

/* 用可爱的小手代替列表圆点 */
.error-tips li::before {
    content: '👉';
    position: absolute;
    left: 0;
    top: 2px;
}

@keyframes shake {
    0% { transform: translateX(-3px) rotate(-5deg); }
    100% { transform: translateX(3px) rotate(5deg); }
}

img.custom-icon {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 保证图片按比例填充，不会被拉伸变扁 */
    display: block;
    border-radius: inherit; /* 自动继承外层容器的圆角 */
}

/* ============ 课程视图容器 ============ */
.course-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

/* ============ 首页专属样式 ============ */
.home-view {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    -webkit-overflow-scrolling: touch;
}

.home-banner {
    background: linear-gradient(135deg, #4FC3F7 0%, #03A9F4 100%);
    border-radius: 20px;
    padding: 30px 40px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    box-shadow: 0 8px 0 #0288D1;
}

.banner-content h2 { font-size: 28px; font-weight: 900; margin-bottom: 10px; text-shadow: 2px 2px 0px rgba(0,0,0,0.1); }
.banner-content p { font-size: 16px; font-weight: bold; opacity: 0.9; }
.banner-mascot { font-size: 60px; animation: float 3s ease-in-out infinite; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.home-section-title {
    color: #0277BD;
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 20px;
    padding-left: 10px;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.home-nav-card {
    background: white;
    border: 4px solid #E1F5FE;
    border-radius: 20px;
    padding: 25px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 6px 0 #B3E5FC;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.home-nav-card:hover { transform: translateY(-5px); border-color: #4FC3F7; box-shadow: 0 10px 0 #81D4FA; }
.home-nav-card:active { transform: translateY(2px); box-shadow: 0 3px 0 #81D4FA; }

.home-nav-icon {
    width: 70px;
    height: 70px;
    background: #FFF9C4;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 35px;
    margin-bottom: 15px;
    border: 3px solid #FFEB3B;
}

.home-nav-card h3 {
    color: #333;
    font-size: 18px;
    font-weight: 900;
    margin-bottom: 15px;
}

.go-btn {
    background: #FFCA28;
    border: none;
    color: #A00000;
    padding: 8px 20px;
    border-radius: 15px;
    font-weight: 900;
    font-size: 14px;
    box-shadow: 0 3px 0 #FF8F00;
    pointer-events: none; /* 让点击穿透到卡片主体 */
}

.home-footer-tips {
    text-align: center;
    color: #90A4AE;
    font-size: 14px;
    font-weight: bold;
    padding-bottom: 100px; /* 防止被底部播放器挡住 */
}

/* 手机端适配首页 */
@media (max-width: 768px) {
    .home-view { padding: 15px; }
    .home-banner { padding: 20px; flex-direction: column; text-align: center; gap: 10px; border-radius: 15px; }
    .banner-content h2 { font-size: 22px; }
    .banner-mascot { display: none; }
    .home-grid { grid-template-columns: repeat(2, 1fr); gap: 15px; }
    .home-nav-card { padding: 15px 10px; }
    .home-nav-icon { width: 50px; height: 50px; font-size: 25px; }
    .home-nav-card h3 { font-size: 15px; }
}

/* =========================================
   响应式设计 (平板与手机适配)
========================================= */
@media (max-width: 992px) {
    .sidebar { width: 200px; }
    .player-info { width: 20%; min-width: 140px; }
    .player-controls { width: 40%; min-width: 240px; }
    .lesson-details h3 { max-width: 100px; }
}

/* =========================================
   响应式设计 (手机端适配)
========================================= */
@media (max-width: 768px) {
    .container { flex-direction: column; }
    
    /* 侧边栏调整为顶部横条 */
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 8px 10px;
        border-right: none;
        border-bottom: 3px solid #FFCA28;
        border-top-right-radius: 0;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
        z-index: 30; /* 确保不被遮挡 */
    }
    .logo { margin-bottom: 0; margin-right: 10px; padding: 6px; flex-shrink: 0; }
    .logo h1 { font-size: 15px; }
    .logo p { display: none; }
    
    .category-list { flex-direction: row; padding-bottom: 4px; padding-right: 0; gap: 6px; }
    .category-btn { padding: 4px 10px; font-size: 12px; border-radius: 10px; border-width: 2px; }
    .category-btn .icon { font-size: 14px; }

    /* 取消高度硬计算，让主内容区自然填充 */
    .main-content { 
        height: auto; 
        flex: 1; 
    }
    
    .header { flex-direction: column; align-items: stretch; padding: 10px 15px; gap: 10px; }
    .header-left { flex-direction: row; justify-content: space-between; align-items: center; }
    .header h2 { font-size: 18px; }
    .search-container { max-width: 100%; }
    .mascot { display: none; }
    
    .sub-category-container { padding: 8px 15px; }
    
    /* === 核心修复 1：为卡片列表底部增加厚厚的内边距 === */
    .playlist-container { 
        padding: 10px 15px 160px; /* 底部预留 160px 空间，防止被播放器遮挡 */
    }
    .playlist { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
    .lesson-card-cover { height: 60px; font-size: 30px; }
    
    /* === 核心修复 2：让播放器高度自适应，并适配手机安全区 === */
    .player { 
        height: auto; /* 取消固定高度，让内部元素自然撑开 */
        flex-direction: column; 
        padding: 12px 15px; 
        gap: 12px; 
        /* 使用 env() 适配 iPhone 等全面屏底部的黑条安全区 */
        padding-bottom: max(15px, env(safe-area-inset-bottom)); 
    }
    .player-info { width: 100%; justify-content: flex-start; }
    .lesson-details h3 { max-width: 65vw; } 
    .progress-container { margin: 0; width: 100%; }
    .player-controls { width: 100%; justify-content: center; gap: 15px; margin-bottom: 5px;}
    .volume-control { display: none; }
}