:root {
    --bg-color: #e6eef5; /* 蓝灰底色 */
    --text-main: #2c3e50;
    --text-sub: #7f8c8d;
    --accent-color: #ff7f3f; /* 橙色高亮 */
    --shadow-light: #ffffff;
    --shadow-dark: #c5d1e0;
}

:root[data-theme="dark"] {
    --bg-color: #1e293b; /* 深色背景，与全局保持一致的色系 */
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --accent-color: #ff7f3f; /* 可以保留或微调 */
    --shadow-light: #26354d; /* 新拟态的亮侧阴影 */
    --shadow-dark: #161d29;  /* 新拟态的暗侧阴影 */
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-color: #1e293b;
        --text-main: #f8fafc;
        --text-sub: #94a3b8;
        --accent-color: #ff7f3f;
        --shadow-light: #26354d;
        --shadow-dark: #161d29;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.tool-container {
    max-width: 600px;
    margin: 0 auto;
}

.metronome-container {
    width: 100%;
    max-width: 500px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 0 auto;
}

/* --- 新拟态面板基础样式 --- */
.panel {
    background-color: var(--bg-color);
    border-radius: 20px;
    padding: 15px 20px;
    box-shadow: 10px 10px 20px var(--shadow-dark), 
                -10px -10px 20px var(--shadow-light);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.panel-header h3 { font-size: 1.1rem; }
.panel-header p { font-size: 0.8rem; color: var(--text-sub); }

/* --- 节拍卡片 --- */
.beat-cards {
    display: flex;
    gap: 15px;
}

.beat-card {
    flex: 1;
    height: 60px;
    border-radius: 12px;
    background-color: var(--bg-color);
    box-shadow: inset 4px 4px 8px var(--shadow-dark), 
                inset -4px -4px 8px var(--shadow-light);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.beat-card.active-beat {
    border-color: var(--accent-color); /* 播放到该拍时高亮边框 */
}

/* --- BPM 控制区 --- */
.bpm-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-bottom: 15px;
}

.bpm-value { text-align: center; }
.bpm-value h1 { font-size: 3.5rem; color: var(--text-main); line-height: 1; }
.bpm-value span { font-size: 0.9rem; color: var(--text-sub); font-weight: bold; letter-spacing: 2px;}

/* 按钮样式 */
.btn-round, .btn-play {
    border: none;
    outline: none;
    background-color: var(--bg-color);
    color: var(--text-main);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 6px 6px 12px var(--shadow-dark), 
                -6px -6px 12px var(--shadow-light);
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-round:active, .btn-play:active {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), 
                inset -4px -4px 8px var(--shadow-light);
}

.btn-round { width: 40px; height: 40px; font-size: 1.2rem; }

/* 拍数增减和小按钮样式 */
.btn-small {
    border: none;
    outline: none;
    background-color: var(--bg-color);
    color: var(--text-main);
    border-radius: 8px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    box-shadow: 4px 4px 8px var(--shadow-dark), 
                -4px -4px 8px var(--shadow-light);
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-small:active {
    box-shadow: inset 2px 2px 4px var(--shadow-dark), 
                inset -2px -2px 4px var(--shadow-light);
}

.beat-count-control {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: bold;
    font-size: 1.1rem;
}

.play-controls {
    display: flex;
    justify-content: center;
}

.btn-play {
    width: 64px;
    height: 64px;
    font-size: 1.8rem;
    color: #009688; /* 播放图标颜色 */
}

.btn-play.playing {
    color: var(--accent-color);
    box-shadow: inset 6px 6px 12px var(--shadow-dark), 
                inset -6px -6px 12px var(--shadow-light);
}

/* --- 滑块样式 --- */
.neumorphic-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: var(--bg-color);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), 
                inset -3px -3px 6px var(--shadow-light);
    outline: none;
}
.neumorphic-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: 4px solid white;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

/* --- BPM 预设按钮 --- */
.bpm-presets {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 15px;
}

.preset-btn {
    border: none;
    outline: none;
    background-color: var(--bg-color);
    color: var(--text-main);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 4px 4px 8px var(--shadow-dark), 
                -4px -4px 8px var(--shadow-light);
    transition: all 0.2s ease;
    min-width: 50px;
}

.preset-btn:active {
    box-shadow: inset 2px 2px 4px var(--shadow-dark), 
                inset -2px -2px 4px var(--shadow-light);
}

.preset-btn.active {
    background-color: var(--accent-color);
    color: white;
    box-shadow: none;
}

/* --- 节奏选择器 --- */
.pattern-selector {
    position: absolute;
    background-color: var(--bg-color);
    border-radius: 16px;
    padding: 10px 15px;
    box-shadow: 10px 10px 20px var(--shadow-dark), 
                -10px -10px 20px var(--shadow-light);
    display: flex;
    gap: 15px;
    z-index: 100;
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid var(--shadow-light);
}

.pattern-selector.hidden {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    pointer-events: none;
}

.pattern-option {
    border: none;
    background: var(--bg-color);
    font-size: 1.5rem;
    cursor: pointer;
    width: auto;
    min-width: 40px;
    padding: 0 10px;
    height: 40px;
    border-radius: 8px;
    color: var(--text-main);
    box-shadow: inset 2px 2px 5px transparent, inset -2px -2px 5px transparent;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pattern-option:hover {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), 
                inset -4px -4px 8px var(--shadow-light);
}

.pattern-option:active {
    color: var(--accent-color);
}