* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #4A90E2; --primary-light: #7AB8FF; --primary-dark: #2C6FBE;
    --success: #52C41A; --error: #FF4D4F; --warning: #FAAD14; --info: #1890FF;
    --bg-primary: #F0F8FF; --bg-secondary: #FFFFFF; --bg-accent: #FFF7E6;
    --text-primary: #262626; --text-secondary: #595959; --text-light: #8C8C8C;
    --shadow: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.18);
    --player-height: 110px;
}

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Marker Felt', cursive, sans-serif;
    font-size: 18px; line-height: 1.6; color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh; padding: 15px;
}

#app { max-width: 800px; margin: 0 auto; min-height: calc(100vh - 30px); display: flex; flex-direction: column; }

/* ===== Header ===== */
.app-header {
    background: var(--bg-secondary); border-radius: 20px; padding: 20px 30px;
    margin-bottom: 15px; box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.app-header h1 {
    font-size: 26px;
    background: linear-gradient(45deg, #FF6B6B, #FFA94D, #FFD93D, #6BCB77, #4D96FF);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.back-link {
    background: var(--bg-primary); color: var(--primary);
    text-decoration: none; padding: 8px 18px; border-radius: 10px;
    font-size: 16px; transition: all 0.3s;
}
.back-link:hover { background: var(--primary); color: white; transform: translateY(-2px); }

/* ===== 文件列表 ===== */
.audio-main { flex: 1; padding-bottom: calc(var(--player-height) + 20px); }

.audio-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 15px;
}

/* ===== 音频卡片 ===== */
.audio-card {
    background: var(--bg-secondary); border-radius: 16px; padding: 18px;
    display: flex; gap: 14px; cursor: pointer; transition: all 0.3s;
    border: 2px solid transparent; position: relative; overflow: hidden;
}
.audio-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--primary-light); }
.audio-card.active { border-color: var(--primary); background: linear-gradient(135deg, #E6F7FF, #F0F8FF); }
.audio-card.completed { border-left: 4px solid var(--success); }
.audio-card.error { border: 2px solid var(--error); background: #FFF1F0; }

.audio-card-icon { font-size: 32px; flex-shrink: 0; width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-primary); border-radius: 12px;
}
.audio-card.active .audio-card-icon { animation: pulse 1.5s ease infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

.audio-card-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.audio-card-name { font-size: 18px; font-weight: bold; color: var(--text-primary); }
.audio-card-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); }
.meta-progress.done { color: var(--success); font-weight: bold; }

.audio-card-bar { height: 6px; background: var(--bg-primary); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary-light), var(--primary)); transition: width 0.3s; border-radius: 3px; }
.audio-card.completed .bar-fill { background: var(--success); }

.audio-card-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-light); }
.last-played { font-style: italic; }

/* 播放动画指示器 */
.playing-indicator {
    position: absolute; bottom: 10px; right: 14px;
    display: flex; gap: 3px; align-items: flex-end;
}
.playing-indicator span {
    width: 3px; background: var(--primary); border-radius: 2px;
    animation: bounce-bar 0.8s ease infinite alternate;
}
.playing-indicator span:nth-child(1) { height: 14px; animation-delay: 0s; }
.playing-indicator span:nth-child(2) { height: 10px; animation-delay: 0.2s; }
.playing-indicator span:nth-child(3) { height: 16px; animation-delay: 0.4s; }
@keyframes bounce-bar { from { height: 6px; } to { height: 18px; } }

/* ===== 底部播放栏 ===== */
.player-bar {
    position: fixed; bottom: 15px; left: 50%; transform: translateX(-50%);
    width: calc(100% - 30px); max-width: 770px;
    background: var(--bg-secondary); border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    padding: 12px 20px; display: flex; align-items: center; gap: 16px;
    z-index: 100; transition: transform 0.3s;
}
.player-bar.error { border: 2px solid var(--error); }

.player-info { flex-shrink: 0; min-width: 0; max-width: 200px; }
.player-title {
    font-size: 16px; font-weight: bold; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.player-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ctrl-btn {
    background: var(--bg-primary); border: none; width: 38px; height: 38px;
    border-radius: 50%; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; color: var(--text-secondary);
}
.ctrl-btn:hover { background: var(--primary-light); color: white; transform: scale(1.1); }
.ctrl-btn:active { transform: scale(0.92); }
.play-btn { background: var(--primary) !important; color: white !important; width: 44px; height: 44px; font-size: 18px; }
.play-btn:hover { background: var(--primary-dark) !important; }

.player-seek { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.time { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; min-width: 36px; text-align: center; }

.seek-bar {
    flex: 1; height: 24px; position: relative; cursor: pointer;
    display: flex; align-items: center; touch-action: none;
}
.seek-bar-bg {
    width: 100%; height: 6px; background: var(--bg-primary);
    border-radius: 3px; position: absolute;
}
.seek-bar-fill {
    height: 6px; background: linear-gradient(90deg, var(--primary-light), var(--primary));
    border-radius: 3px; position: relative; max-width: 100%;
    transition: width 0.1s linear;
}
.seek-bar:active .seek-bar-fill { transition: none; }

.player-volume { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.vol-icon { font-size: 18px; cursor: pointer; user-select: none; }
.volume-bar {
    width: 70px; height: 24px; position: relative; cursor: pointer;
    display: flex; align-items: center;
}
.volume-bar::before {
    content: ''; position: absolute; width: 100%; height: 4px;
    background: var(--bg-primary); border-radius: 2px;
}
.volume-bar-fill {
    height: 4px; background: var(--primary); border-radius: 2px;
    position: relative; transition: width 0.1s;
}

.speed-select {
    padding: 4px 8px; border: 2px solid var(--primary-light);
    border-radius: 8px; font-size: 13px; font-family: inherit;
    background: var(--bg-primary); cursor: pointer; color: var(--primary);
    flex-shrink: 0;
}
.speed-select:focus { outline: none; border-color: var(--primary); }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); grid-column: 1 / -1; }
.empty-state .icon { font-size: 64px; margin-bottom: 15px; }

/* ===== 响应式：手机端 ===== */
@media (max-width: 600px) {
    body { font-size: 16px; padding: 10px; }
    .app-header { padding: 15px 20px; }
    .app-header h1 { font-size: 22px; }

    .audio-list { grid-template-columns: 1fr; }

    .player-bar {
        flex-direction: column; gap: 8px; padding: 10px 16px;
        bottom: 10px; width: calc(100% - 20px);
    }
    .player-info { max-width: 100%; width: 100%; text-align: center; }
    .player-seek { width: 100%; }
    .player-volume { display: none; } /* 手机端用系统音量 */
    .speed-select { font-size: 12px; }

    .ctrl-btn { width: 36px; height: 36px; font-size: 15px; }
    .play-btn { width: 42px; height: 42px; }

    :root { --player-height: 170px; }
}

/* ===== 响应式：平板 ===== */
@media (min-width: 601px) and (max-width: 768px) {
    .audio-list { grid-template-columns: 1fr; }
}
