/* =========================================
   1. 核心容器：全屏覆盖层 (这是之前丢失的部分)
   ========================================= */
.training-overlay {
    /* 关键：固定定位，脱离文档流，覆盖在最上层 */
    position: fixed; 
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    
    /* 视觉风格：毛玻璃背景 */
    background: rgba(230, 240, 255, 0.6); 
    backdrop-filter: blur(15px); 
    z-index: 999; 
    
    /* 布局方式：让内部内容居中/垂直排列 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    box-sizing: border-box;

    /* 动画过渡 */
    opacity: 1;
    visibility: visible;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 隐藏状态：当加上 hidden 类时完全消失 */
.training-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* 防止点到隐藏的层 */
}

/* 当隐藏时，内容稍微往下沉一点，造成“弹起”的效果 */
.hidden .dashboard-grid, 
.hidden .top-bar {
    transform: translateY(20px) scale(0.98);
}

/* =========================================
   2. 顶部导航栏
   ========================================= */
.top-bar {
    width: 100%;
    max-width: 1100px; /* 限制最大宽度，与网格对齐 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #4a5568;
    transition: transform 0.4s ease;
}

.page-title {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: #334155;
}

.version-tag {
    font-size: 0.8rem;
    background: rgba(255,255,255,0.6);
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.8);
    color: #64748b;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.8rem;
    color: #F5A9B8;
    cursor: pointer;
    transition: transform 0.3s ease;
    padding: 5px;
    border-radius: 50%;
}
.icon-btn:hover {
    background: rgba(255,255,255,0.5);
    transform: rotate(90deg);
}

/* =========================================
   3. 核心布局：2x2 Dashboard 网格
   ========================================= */
.dashboard-grid {
    display: grid;
    /* 定义两列，宽度相等 */
    grid-template-columns: 1fr 1fr; 
    /* 定义两行，高度分别占比: 上面那行稍微高一点 */
    grid-template-rows: 1.2fr 0.8fr; 
    gap: 20px;
    
    width: 100%;
    max-width: 1100px;
    height: 75vh; /* 占据屏幕高度的 75% */
    
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========================================
   4. 通用玻璃卡片 (Glass Card)
   ========================================= */
.glass-card {
    background: rgba(255, 255, 255, 0.75); /* 比背景稍微不透明一点 */
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 
        0 10px 40px rgba(0,0,0,0.03),
        inset 0 0 0 1px rgba(255,255,255, 0.5);
    
    display: flex;
    flex-direction: column;
    overflow: hidden;
    
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 
        0 20px 40px rgba(91, 206, 250, 0.15), /* 悬停时的蓝色光晕 */
        inset 0 0 0 1px rgba(255,255,255, 1);
}

/* --- 卡片内部结构 --- */
.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-weight: 700;
    font-size: 0.95rem;
    color: #64748b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.4);
}

.card-icon {
    margin-right: 8px;
    font-size: 1.1rem;
}

.card-body {
    flex: 1; /* 撑满剩余空间 */
    position: relative;
    padding: 10px;
    display: flex; /* 默认弹性布局，方便内容居中 */
}

.card-footer {
    padding: 12px 20px;
    background: rgba(255,255,255,0.5);
    border-top: 1px solid rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================
   5. 各个功能模块的特定样式
   ========================================= */

/* --- 模块 A: 音高分析 (左上) --- */
.relative-box {
    width: 100%;
    height: 100%;
}
#audio-canvas {
    width: 100%;
    height: 100%;
    /* 让波形图稍微透明一点，更有科技感 */
    opacity: 0.9; 
}
.pitch-overlay {
    position: absolute;
    top: 15px;
    right: 25px;
    text-align: right;
    pointer-events: none; /* 让鼠标穿透数字，防止挡住 Canvas */
}
.huge-number {
    font-size: 3.5rem;
    font-weight: 800;
    color: #5BCEFA;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: block;
    line-height: 0.9;
    text-shadow: 0 4px 10px rgba(91, 206, 250, 0.3);
}
.unit {
    font-size: 1rem;
    color: #94a3b8;
    font-weight: bold;
}
.live-tag {
    background: #F5A9B8;
    color: white;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 10px;
    letter-spacing: 1px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

.action-btn-small {
    background: white;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.action-btn-small:hover {
    border-color: #5BCEFA;
    color: #0ea5e9;
    transform: translateY(-1px);
}

/* --- 模块 B: 共鸣 (右上) --- */
.center-content {
    align-items: center;
    justify-content: center;
}
.placeholder-chart {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    width: 80%;
    height: 60%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #94a3b8;
}

/* --- 模块 C: 性别置信度 (左下) --- */
.column-content {
    flex-direction: column;
    justify-content: center;
    padding: 0 40px; /* 两侧留白 */
    gap: 15px;
}
.gender-bar-container {
    width: 100%;
}
.gender-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 8px;
    font-weight: bold;
}
.progress-track {
    height: 16px;
    background: #f1f5f9;
    border-radius: 20px;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 20px;
    /* 渐变色：从男声蓝 -> 中性紫 -> 女声粉 */
    background: linear-gradient(90deg, #5BCEFA 0%, #a78bfa 50%, #F5A9B8 100%);
    opacity: 0.3; /* 默认底色淡一点 */
    width: 100%; /* 全宽背景 */
}
.indicator-needle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #475569;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    transition: left 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    border-radius: 2px;
}
.confidence-score {
    text-align: center;
    font-size: 0.9rem;
    color: #64748b;
}

/* --- 模块 D: 录音机 (右下) --- */
.list-content {
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: auto; /* 允许滚动 */
    padding: 0;
}
.record-item {
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #64748b;
    cursor: pointer;
    transition: background 0.2s;
}
.record-item:hover { background: #f8fafc; }
.record-item.active {
    background: #f0f9ff;
    color: #0284c7;
    font-weight: bold;
    border-left: 3px solid #5BCEFA;
}

.row-controls {
    gap: 20px;
}
.circle-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1rem;
    color: #475569;
}
.circle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(0,0,0,0.12);
}
.record-btn {
    background: #F5A9B8;
    border: 3px solid white;
    box-shadow: 0 4px 10px rgba(245, 169, 184, 0.4);
}
.record-btn:active {
    transform: scale(0.95);
    background: #be185d;
}

/* 动画定义 */
@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

/* =========================================
   6. 📱 训练室手机端适配 (v0.13)
   ========================================= */
@media (max-width: 768px) {
    /* 让顶部导航栏更紧凑 */
    .training-overlay {
        padding: 10px; /* 减少边距 */
        justify-content: flex-start; /* 内容从顶部开始，允许滚动 */
        overflow-y: auto; /* 允许整个覆盖层滚动 */
    }

    .top-bar {
        margin-top: env(safe-area-inset-top); /* 避开刘海 */
        margin-bottom: 10px;
    }

    .page-title {
        font-size: 1.2rem;
    }

    /* 💥 核心修改：网格变单列 */
    .dashboard-grid {
        display: flex; /* 改用 Flex 布局 */
        flex-direction: column; /* 垂直排列 */
        height: auto; /* 高度自适应内容 */
        gap: 15px;
        padding-bottom: 40px; /* 底部留白给手指 */
    }

    /* 让每个卡片在手机上都有固定的高度，防止太扁 */
    .glass-card {
        min-height: 220px; 
    }

    /* 特殊调整：波形图卡片可以高一点 */
    .card-pitch {
        min-height: 260px;
    }
    
    /* 录音机卡片不需要太高 */
    .card-record {
        min-height: 180px;
    }
}