/* CSS变量定义 */
:root {
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-container: rgba(255, 255, 255, 0.95);
    --bg-color: #ffffff; /* 添加背景色变量 */
    --card-bg: #f8f9fa; /* 添加卡片背景色变量 */
    --text-color: #333333; /* 添加文本颜色变量 */
    --primary-color: #1565c0; /* 使用开始按钮的颜色 */
    --text-primary: #333;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --accent-color: #1565c0; /* 统一使用开始按钮颜色 */
    --accent-hover: #1976d2; /* 悬停时的颜色 */
    --success-color: #48bb78;
    --success-hover: #38a169;
    --danger-color: #f56565;
    --danger-hover: #e53e3e;
    --warning-color: #ed8936;
    --warning-hover: #dd6b20;
    --shadow-light: 0 2px 6px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 20px 40px rgba(0, 0, 0, 0.1);
    --pulse-color: #1565c0; /* 脉冲颜色也统一 */
}

/* 黑暗模式变量 */
[data-theme="dark"] {
    --bg-primary: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    --bg-container: rgba(45, 55, 72, 0.95);
    --bg-color: #2d3748; /* 暗黑模式背景色 */
    --card-bg: #1a202c; /* 改为更深的背景色，增加对比度 */
    --text-color: #f7fafc; /* 暗黑模式文本颜色 */
    --primary-color: #1565c0; /* 使用开始按钮的颜色 */
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #a0aec0;
    --border-color: #718096; /* 改为更亮的边框色，增加对比度 */
    --accent-color: #1565c0; /* 统一使用开始按钮颜色 */
    --accent-hover: #1976d2; /* 悬停时的颜色 */
    --shadow-light: 0 2px 6px rgba(0, 0, 0, 0.5); /* 增强阴影 */
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.6); /* 增强阴影 */
    --shadow-heavy: 0 20px 40px rgba(0, 0, 0, 0.5); /* 增强阴影 */
    --pulse-color: #1565c0; /* 脉冲颜色也统一 */
}

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all 0.3s ease;
    overflow: hidden; /* 防止整体滚动 */
    touch-action: manipulation; /* 防止双击缩放和拖动 */
    -webkit-overflow-scrolling: touch;
    position: fixed; /* 固定body位置 */
    width: 100%;
    height: 100%;
}

.container {
    background: var(--bg-container);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-heavy);
    max-width: 600px;
    width: 90%;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    touch-action: manipulation; /* 防止拖动和缩放 */
    user-select: none; /* 防止文本选择 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
    padding-top: 1rem;
}

.header-controls {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex-direction: column;
}

.articles-link {
    background: var(--accent-color);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.articles-link:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

h1 {
    font-size: 2.5rem;
    color: var(--text-secondary);
    font-weight: 300;
    margin-top: 0.5rem;
}

h2 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: left;
    font-weight: 500;
}

/* 主题切换按钮 */
.theme-toggle {
    margin-top: 0.5rem;
}

.theme-btn {
    background: #1565c0;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.theme-btn:hover {
    background: #1976d2;
    transform: scale(1.1);
}

/* BPM控制区域 - 移除上方边框 */
.bpm-section {
    margin-top: 10px;
    margin-bottom: 1rem; /* 从1.5rem减少到1rem */
}

/* 拍号和节拍细分并排布局 */
.time-signature-subdivision-container {
    display: flex;
    gap: 2rem;
    margin-top: 10px;
    margin-bottom: 1rem; /* 从1.5rem减少到1rem */
    justify-content: center;
    align-items: flex-start;
}

.time-signature-section,
.subdivision-section {
    flex: 1;
    max-width: 250px;
    margin-bottom: 0;
}

/* 视觉反馈和控制按钮上移 */
.visual-feedback-section {
    margin-top: 10px;
    margin-bottom: 0.8rem; /* 从1rem减少到0.8rem */
}

.controls-section {
    margin-top: 10px;
    margin-bottom: 50px; /* 确保与底边有50px距离 */
}

/* 桌面端隐藏如何练习按钮 */
.articles-link {
    display: none; /* 在所有设备上隐藏 */
}

.header-right {
    display: none; /* 在所有设备上隐藏 */
}

/* 移动端全屏显示 */
@media (max-width: 768px) {
    html {
        overflow: hidden; /* 防止html滚动 */
        touch-action: manipulation;
        -webkit-text-size-adjust: 100%;
    }
    
    body {
        padding: 0;
        margin: 0;
        overflow: hidden;
        touch-action: manipulation;
        position: fixed;
        width: 100%;
        height: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    .container {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        padding: 1rem;
        min-height: 100vh;
        box-shadow: none;
        padding-top: 2rem; /* 增加顶部内边距，向下移动20px */
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
        overflow: hidden;
        height: 100vh;
        max-height: 100vh;
        overflow-y: auto; /* 只允许垂直滚动内容 */
        -webkit-overflow-scrolling: touch;
    }
    
    /* 移动端设置图标位置调整 */
    .header-left {
        position: absolute;
        top: 0px; /* 从10px改为0px，再往上移10px */
        left: 10px; /* 保持距离左边界10px */
        display: flex;
        align-items: flex-start;
    }
    
    /* 标题向下移动20px */
    header {
        margin-bottom: 2rem; /* 增加底部间距 */
        margin-top: 20px; /* 向下移动20px */
    }
    
    /* BPM控制区域向下移动并增加间距 */
    .bpm-section {
        margin-top: 20px; /* 向下移动20px */
        margin-bottom: 1.5rem; /* 增加底部间距 */
    }
    
    /* 拍号和节拍细分向下移动并增加间距 */
    .time-signature-subdivision-container {
        display: flex;
        gap: 1rem;
        margin-top: 20px; /* 向下移动20px */
        margin-bottom: 1.5rem; /* 增加底部间距 */
        justify-content: center;
        align-items: flex-start;
        flex-direction: row; /* 强制并排显示 */
    }
    
    .time-signature-section,
    .subdivision-section {
        flex: 1;
        max-width: 45%;
    }
    
    /* 视觉反馈向下移动并增加间距 */
    .visual-feedback-section {
        margin-top: 20px; /* 向下移动20px */
        margin-bottom: 1.5rem; /* 增加底部间距 */
    }
    
    /* 控制按钮向下移动 */
    .controls-section {
        margin-top: 20px; /* 向下移动20px */
        margin-bottom: 50px; /* 确保移动端也有50px底部距离 */
    }
    
    .time-signature-controls {
        justify-content: flex-start;
    }
    
    .subdivision-controls {
        justify-content: flex-start;
    }
    
    /* 节拍细分控件优化 - 缩小并强制单行显示 */
    .subdivision-btn {
        padding: 0.4rem 0.5rem; /* 进一步缩小内边距 */
        border: 2px solid var(--border-color);
        border-radius: 6px; /* 稍微减小圆角 */
        background: var(--bg-container);
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 0.75rem; /* 进一步缩小字体 */
        font-weight: bold;
        color: var(--text-primary);
        min-width: 32px; /* 进一步缩小最小宽度 */
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap; /* 防止文字换行 */
    }
    
    .note-symbol {
        font-size: 0.85rem; /* 进一步缩小音符符号 */
    }
    
    .subdivision-controls {
        display: flex;
        gap: 0.25rem; /* 进一步减小间距 */
        justify-content: flex-start;
        flex-wrap: nowrap; /* 强制不换行 */
        overflow-x: auto; /* 如果内容过宽，允许水平滚动 */
    }
}

.bpm-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bpm-slider-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.bpm-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.bpm-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1565c0; /* 使用开始按钮颜色 */
    cursor: pointer;
    box-shadow: var(--shadow-light);
    transition: all 0.2s ease;
}

.bmp-slider::-webkit-slider-thumb {
    background: #1565c0; /* 使用开始按钮颜色 */
}

.bpm-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: #1976d2; /* 悬停时颜色 */
}

.bpm-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bpm-input {
    width: 80px;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-primary);
    background: var(--bg-container);
    outline: none;
    transition: border-color 0.2s ease;
}

.bpm-input:focus {
    border-color: var(--accent-color);
}

.bpm-label {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-secondary);
}

/* 拍号选择 */
.time-signature-section {
    margin-bottom: 2rem;
}

/* 拍号section的标题左对齐 */
.time-signature-section h2 {
    text-align: left;
    margin-bottom: 1rem;
}

.time-signature-controls {
    display: flex;
    justify-content: flex-start;
}

.time-signature-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-container);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-light);
}

.time-signature-select {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    min-width: 50px;
    text-align: center;
}

.time-signature-divider {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-muted);
}

/* 节拍重音设置 - 网格布局 */
.beat-accents-section {
    margin-bottom: 2rem;
}

.beat-accents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.5rem;
    max-width: 400px;
    margin: 0 auto;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.beat-accent-btn {
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-container);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--text-primary);
    min-height: 50px;
    font-size: 0.9rem;
    position: relative;
}

.beat-accent-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-light);
}

.beat-accent-btn.strong {
    background: #4fc3f7;
    border-color: #29b6f6;
    color: white;
    box-shadow: 0 2px 8px rgba(79, 195, 247, 0.3);
}

.beat-accent-btn.medium {
    background: #81c784;
    border-color: #66bb6a;
    color: white;
    box-shadow: 0 2px 8px rgba(129, 199, 132, 0.3);
}

.beat-accent-btn.weak {
    background: var(--bg-container);
    border-color: var(--border-color);
    color: var(--text-muted);
}

/* Subdivision功能 */
.subdivision-section {
    margin-bottom: 2rem;
}

/* 节拍细分section的标题左对齐 */
.subdivision-section h2 {
    text-align: left;
    margin-bottom: 1rem;
}

.subdivision-controls {
    display: flex;
    gap: 0.33rem;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.subdivision-btn {
    padding: 0.5rem 0.67rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-container);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.87rem;
    font-weight: bold;
    color: var(--text-primary);
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.subdivision-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: #1565c0;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.2);
}

.subdivision-btn.active {
    background: #1565c0; /* 使用开始按钮颜色 */
    border-color: #1565c0;
    color: white;
    box-shadow: 0 4px 15px rgba(21, 101, 192, 0.3);
}

.note-symbol {
    font-size: 1rem;
}

/* 音色选择 */
.sound-section {
    margin-bottom: 2rem;
}

.sound-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.1rem;
    background: var(--bg-container);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.sound-select:focus {
    border-color: var(--accent-color);
}

/* 视觉反馈 - 改进的设计 */
.visual-feedback-section {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.beat-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.beat-circle {
    width: 168px;
    height: 168px;
    border-radius: 50%;
    background: var(--border-color);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.beat-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--pulse-color) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.15s ease;
}

.beat-number {
    font-size: 2.4rem;
    font-weight: bold;
    color: var(--text-primary);
    z-index: 2;
    transition: all 0.15s ease;
}

.beat-circle.active {
    background: #1565c0; /* 使用开始按钮颜色 */
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(21, 101, 192, 0.4);
}

.beat-circle.active .beat-pulse {
    opacity: 0.6;
    transform: scale(1.2);
    animation: pulse-wave 0.3s ease-out;
}

.beat-circle.active .beat-number {
    color: white;
    transform: scale(1.1);
}

.beat-circle.accent {
    background: #1565c0;
    border-color: #1976d2;
    box-shadow: 0 0 25px rgba(21, 101, 192, 0.6);
}

@keyframes pulse-wave {
    0% {
        transform: scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.beat-counter {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 节拍点样式 */
.beat-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--text-muted);
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.beat-dot.active {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.beat-dot.active.strong {
    background: #4fc3f7;
    border-color: #29b6f6;
    color: white;
    box-shadow: 0 4px 12px rgba(79, 195, 247, 0.4);
}

.beat-dot.active.medium {
    background: #81c784;
    border-color: #66bb6a;
    color: white;
    box-shadow: 0 4px 12px rgba(129, 199, 132, 0.4);
}

.beat-dot.active.weak {
    background: var(--accent-color);
    border-color: var(--accent-hover);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 主圆圈脉冲效果 */
.beat-circle {
    width: 144px;
    height: 144px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    transition: all 0.1s ease;
}

.beat-circle.pulse {
    animation: beatPulse 0.2s ease-out;
}

@keyframes beatPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0.3);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 20px rgba(102, 126, 234, 0);
    }
}

/* 节拍模式容器 */
.beat-pattern {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.beat-dot.current {
    background: #1565c0;
    border-color: #1976d2;
    color: white;
    transform: scale(1.3);
    box-shadow: 0 0 15px rgba(21, 101, 192, 0.3);
}

.beat-dot.strong {
    border-color: #4fc3f7;
    background: rgba(79, 195, 247, 0.2);
}

.beat-dot.medium {
    border-color: #81c784;
    background: rgba(129, 199, 132, 0.2);
}

/* 头部布局调整 */
header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
    position: relative;
}

.header-left {
    position: absolute;
    top: 10px; /* 距离上边界10px */
    left: 10px; /* 距离左边界10px */
    display: flex;
    align-items: flex-start;
}

.settings-btn {
    background: var(--accent-color);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    box-shadow: var(--shadow-light);
}

.settings-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

header h1 {
    text-align: center;
    margin: 0;
    font-size: 2.5rem;
    color: #1565c0; /* 与开始按钮同色 */
    font-weight: 700;
    flex: none; /* 移除flex: 1，确保完全居中 */
}

/* 暗黑模式下标题颜色调整 */
[data-theme="dark"] header h1 {
    color: #ffffff; /* 暗黑模式下标题显示为白色 */
}

/* 设置按钮样式 */
.settings-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.8rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    color: var(--text-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.settings-btn:hover {
    background: #1565c0;
    color: white;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 15px rgba(21, 101, 192, 0.3);
}

/* 大按钮样式 */
/* 通用按钮基础样式 */
button {
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

/* 开始按钮样式增强 */
.play-stop-btn {
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    color: white;
    border: none;
    border-radius: 25px; /* 添加圆角 */
    padding: 1.2rem 2rem;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(21, 101, 192, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 auto; /* 居中显示 */
    min-height: 60px;
}

.play-stop-btn:hover {
    background: linear-gradient(135deg, #1976d2, #1565c0);
    box-shadow: 0 8px 25px rgba(21, 101, 192, 0.5);
    transform: translateY(-3px) scale(1.02);
}

.play-stop-btn.playing {
    background: linear-gradient(135deg, #f44336, #e91e63);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
}

.play-stop-btn.playing:hover {
    background: linear-gradient(135deg, #e53935, #d81b60);
    box-shadow: 0 8px 25px rgba(244, 67, 54, 0.5);
}

.play-stop-btn.large-btn {
    width: 50%;
    max-width: 400px;
    min-width: 200px;
    padding: 1.5rem 3rem;
    font-size: 1.4rem;
    font-weight: 700;
    border-radius: 30px; /* 更大的圆角 */
}

/* 深蓝色开始按钮 */
.play-stop-btn.deep-blue {
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    box-shadow: 0 6px 20px rgba(21, 101, 192, 0.4);
}

.play-stop-btn.deep-blue:hover {
    background: linear-gradient(135deg, #1976d2, #1565c0);
    box-shadow: 0 8px 25px rgba(21, 101, 192, 0.5);
    transform: translateY(-3px);
}

.play-stop-btn.deep-blue.playing {
    background: linear-gradient(135deg, #f44336, #e91e63);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
}

/* 设置模态框样式增强 */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9); /* 亮色模式下使用白色半透明 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

/* 为暗黑模式单独设置模态框背景 */
[data-theme="dark"] .settings-modal {
    background: rgba(26, 32, 44, 0.9); /* 使用更深的背景色，增加对比度 */
}

/* 暗黑模式下的设置项增强对比度 */
[data-theme="dark"] .setting-item {
    background: #1a202c; /* 更深的背景 */
    border: 2px solid #4a5568; /* 更明显的边框 */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); /* 增强阴影 */
}

/* 暗黑模式下的模态框内容增强 */
[data-theme="dark"] .modal-content {
    background: #2d3748;
    border: 2px solid #63b3ed; /* 使用主色调作为边框 */
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4); /* 增强阴影 */
}

/* 暗黑模式下的切换开关增强 */
[data-theme="dark"] .toggle-label {
    background: #4a5568; /* 更明显的背景色 */
    border: 1px solid #718096; /* 添加边框 */
}

/* 暗黑模式下BPM滑块颜色统一 */
[data-theme="dark"] .bpm-slider::-webkit-slider-thumb {
    background: #1565c0; /* 使用开始按钮颜色 */
}

[data-theme="dark"] .bpm-slider::-webkit-slider-thumb:hover {
    background: #1976d2; /* 悬停时颜色 */
}

/* 暗黑模式下节拍细分控件激活状态颜色统一 */
[data-theme="dark"] .subdivision-btn.active {
    background: #1565c0; /* 使用开始按钮颜色 */
    border-color: #1565c0;
    color: white;
    box-shadow: 0 4px 15px rgba(21, 101, 192, 0.4);
}

[data-theme="dark"] .subdivision-btn:hover {
    border-color: #1565c0;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.3);
}

/* 暗黑模式下视觉效果圆形颜色统一 */
[data-theme="dark"] .beat-circle.active {
    background: #1565c0; /* 使用开始按钮颜色 */
    border-color: #1976d2;
    box-shadow: 0 0 20px rgba(21, 101, 192, 0.6);
}

[data-theme="dark"] .beat-circle.accent {
    background: #1565c0;
    border-color: #1976d2;
    box-shadow: 0 0 25px rgba(21, 101, 192, 0.8);
}

/* 暗黑模式下节拍点颜色统一 */
[data-theme="dark"] .beat-dot.current {
    background: #1565c0;
    border-color: #1976d2;
    box-shadow: 0 0 15px rgba(21, 101, 192, 0.5);
}

/* 暗黑模式下音量滑块颜色统一 */
[data-theme="dark"] .volume-slider::-webkit-slider-thumb {
    background: #1565c0;
    border: 2px solid white;
}

[data-theme="dark"] .volume-slider::-webkit-slider-thumb:hover {
    background: #1976d2;
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.4);
}

/* 暗黑模式下切换开关激活状态颜色统一 */
[data-theme="dark"] .toggle-input:checked + .toggle-label {
    background: #1565c0;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.3);
}

/* 暗黑模式下的音色选择增强 */
[data-theme="dark"] .sound-select {
    background: #1a202c; /* 更深的背景 */
    border: 2px solid #4a5568; /* 更明显的边框 */
    color: #f7fafc; /* 确保文字清晰 */
}

[data-theme="dark"] .sound-select:focus {
    border-color: #63b3ed;
    box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.3);
}

.modal-content {
    background: var(--bg-color);
    border: 2px solid var(--accent-color);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2); /* 减轻阴影 */
    animation: modalSlideIn 0.4s ease-out;
}

.modal-body {
    padding: 2rem;
    background: var(--bg-color);
}

.setting-item {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 15px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); /* 减轻阴影 */
}

.setting-item label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--text-color);
    font-size: 1.1rem;
}

/* 音量控制样式增强 */
.volume-control {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.volume-slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1565c0;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    border: 2px solid white;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #1976d2;
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.3);
}

.volume-value {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
    color: var(--accent-color);
    font-size: 1rem;
}

/* 切换开关样式增强 */
.toggle-switch {
    position: relative;
}

.toggle-input {
    display: none;
}

.toggle-label {
    display: block;
    width: 70px;
    height: 35px;
    background: var(--border-color);
    border-radius: 17.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 29px;
    height: 29px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.toggle-input:checked + .toggle-label {
    background: #1565c0;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.2);
}

.toggle-input:checked + .toggle-label .toggle-slider {
    transform: translateX(35px);
}

/* 音色选择样式增强 */
.sound-select {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sound-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.2);
}

/* 设置项并排布局 */
.setting-group label {
    margin-right: 10px;
    white-space: nowrap;
}

/* 移动端响应式 */
@media (max-width: 768px) {
    .play-stop-btn.large-btn {
        width: 100%;
        max-width: none;
        padding: 1.8rem 2rem;
        font-size: 1.5rem;
        border-radius: 25px;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-header,
    .modal-body {
        padding: 1.5rem;
    }
    
    .setting-item {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    header {
        justify-content: center;
        position: relative;
    }
    
    .header-left {
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
    }
    
    header h1 {
        font-size: 2rem;
        text-align: center;
        flex: none;
    }
    
    .settings-btn {
        padding: 0.6rem;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.8rem;
        padding-top: 2rem; /* 保持顶部内边距 */
    }
    
    .header-left {
        top: 0px; /* 小屏幕也保持距离上边界0px */
        left: 10px; /* 距离左边界10px */
    }
    
    /* 小屏幕下进一步增加间距 */
    header {
        margin-bottom: 2rem;
        margin-top: 20px;
    }
    
    .bpm-section {
        margin-top: 20px;
        margin-bottom: 1.5rem;
    }
    
    .time-signature-subdivision-container {
        flex-direction: row;
        gap: 0.8rem;
        margin-top: 20px;
        margin-bottom: 1.5rem;
    }
    
    .visual-feedback-section {
        margin-top: 20px;
        margin-bottom: 1.5rem;
    }
    
    .controls-section {
        margin-top: 20px;
        margin-bottom: 50px;
    }
    
    .time-signature-section,
    .subdivision-section {
        flex: 1;
        max-width: 48%;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .time-signature-controls {
        justify-content: flex-start;
    }
    
    .subdivision-controls {
        justify-content: flex-start;
    }
    
    /* 小屏幕下进一步优化节拍细分控件 */
    .subdivision-btn {
        padding: 0.35rem 0.4rem; /* 更小的内边距 */
        font-size: 0.7rem; /* 更小的字体 */
        min-width: 28px; /* 更小的最小宽度 */
        border-radius: 4px; /* 更小的圆角 */
    }
    
    .note-symbol {
        font-size: 0.8rem;
    }
    
    .subdivision-controls {
        gap: 0.2rem; /* 更小的间距 */
        justify-content: flex-start;
        flex-wrap: nowrap;
    }
    
    /* 确保subdivision-section有足够空间 */
    .subdivision-section {
        flex: 1;
        max-width: 48%;
        min-width: 0; /* 允许收缩 */
    }
    
    /* 移动端响应式调整 */
    .setting-group {
        justify-content: space-between;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-100px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-color);
    border-radius: 18px 18px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    text-align: left;
}

/* 设置关闭按钮样式增强 */
.close-btn {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0.2rem 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
}

.close-btn:hover {
    background: var(--border-color);
    color: var(--text-color);
    transform: scale(1.1);
}

/* 设置有变更时的样式 */
.close-btn.settings-changed {
    color: #4caf50; /* 绿色对勾 */
    background: rgba(76, 175, 80, 0.1);
    font-size: 1.8rem;
    animation: pulse-check 2s infinite;
}

.close-btn.settings-changed:hover {
    background: rgba(76, 175, 80, 0.2);
    color: #388e3c;
    transform: scale(1.15);
}

/* 暗黑模式下的设置变更样式 */
[data-theme="dark"] .close-btn.settings-changed {
    color: #66bb6a;
    background: rgba(102, 187, 106, 0.15);
}

[data-theme="dark"] .close-btn.settings-changed:hover {
    background: rgba(102, 187, 106, 0.25);
    color: #81c784;
}

/* 对勾脉冲动画 */
@keyframes pulse-check {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* 移除之前的并排布局样式 */
.setting-row {
    display: block; /* 改为普通块级显示 */
}

.setting-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}