/* --- 기본 및 페이지 레이아웃 --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    background-color: #f0f0f0;
    font-family: sans-serif;
}

/* --- 상단 글로벌 컨트롤 컨테이너 --- */
.global-controls-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 450px;
    margin: 0 auto 20px auto;
    background-color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    box-sizing: border-box;
}
.volume-control-wrapper { display: flex; align-items: center; gap: 10px; width: 100%; }
.volume-control-wrapper input { width: 100%; }
.volume-control-wrapper span { font-weight: bold; font-size: 0.9em; white-space: nowrap; min-width: 55px; text-align: left; }

/* ▼▼▼ [추가] 볼륨 조절 버튼 스타일 ▼▼▼ */
#toggle-volume-controls-btn {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.1s;
}
#toggle-volume-controls-btn:hover {
    background-color: #e0e0e0;
}
/* ▲▲▲ [추가] ▲▲▲ */
    
/* --- 메인 앱 컨테이너 (레이아웃의 핵심) --- */
.app-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 20px;
    width: 100%;
}

/* --- 메트로놈 모듈 공통 스타일 --- */
.metronome {
    width: 350px;
    background-color: white;
    padding: 20px 25px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    text-align: center;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}
.metronome h1, .metronome h2 { color: #333; margin-top: 0; }

.hidden {
    display: none !important;
}

/* --- 모듈 위치 지정 --- */
.rhythm-module { grid-column: 1; justify-self: end; }
.main-metronome { grid-column: 2; }
.chord-module { grid-column: 3; justify-self: start; }

/* --- 나머지 UI 요소들 --- */
.bpm-presets { display: flex; justify-content: center; gap: 10px; margin-bottom: 15px; }
.preset-btn { background-color: #f0f0f0; border: 1px solid #ddd; border-radius: 5px; padding: 5px 12px; font-size: 0.9em; font-weight: bold; color: #555; cursor: pointer; transition: all 0.1s; }
.preset-btn:hover { background-color: #e0e0e0; border-color: #ccc; }
.preset-btn.active { background-color: #4CAF50; color: white; border-color: #4CAF50; }
.bpm-controls { display: flex; justify-content: center; align-items: center; gap: 15px; margin: 20px 0; }
.bpm-display { font-size: 2em; white-space: nowrap; }
#stopwatch-display { cursor: pointer; user-select: none; }
.bpm-btn { width: 45px; height: 45px; font-size: 1.8em; font-weight: bold; color: white; background-color: #4CAF50; border: none; border-radius: 10px; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; line-height: 1; transition: all 0.1s; }
.bpm-btn:hover { background-color: #45a049; }
.bpm-btn:active { background-color: #3e8e41; transform: scale(0.95); }
.bpm-slider input { width: 100%; }
.time-signature { margin-top: 20px; font-size: 1em; }
.time-signature input { width: 50px; font-size: 1em; text-align: center; margin-left: 10px; }
#beat-indicator-container { display: flex; justify-content: center; gap: 10px; margin-top: 20px; height: 24px; }
.beat-dot { width: 20px; height: 20px; border-radius: 50%; background-color: #e0e0e0; transition: all 0.1s ease-in-out; cursor: pointer; }
.beat-dot:hover { filter: brightness(0.9); }
.beat-dot.state-accent { background-color: #4CAF50; }
.beat-dot.state-tick { background-color: #2196F3; }
.beat-dot.state-silent { background-color: #cccccc; }
.beat-dot.active { transform: scale(1.2); box-shadow: 0 0 10px rgba(0,0,0,0.5); }
#chord-display { font-size: 4em; font-weight: bold; color: #333; height: 100px; display: flex; justify-content: center; align-items: center; margin-top: 20px;}
.chord-input-area { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
#chord-input { flex-grow: 1; width: auto; padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-family: sans-serif; font-size: 1em; resize: vertical; }
.random-chord-toggle { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.rhythm-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
.rhythm-cell { width: 100%; padding-top: 100%; position: relative; background-color: #e0e0e0; border-radius: 5px; transition: all 0.1s; cursor: pointer; }
.rhythm-cell:hover { background-color: #d0d0d0; transform: scale(1.05); }
.rhythm-cell.active { background-color: #ff9800; }
.rhythm-cell.accent { background-color: #f44336; transform: scale(1.05); }
.rhythm-cell.playing { transform: scale(1.1); box-shadow: 0 0 10px #ff9800; }
.preview-label { font-size: 0.8em; color: #888; margin-top: 20px; margin-bottom: 5px; text-align: left; }
#rhythm-preview-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.preview-cell { width: 100%; padding-top: 100%; position: relative; background-color: #f0f0f0; border-radius: 3px; }
.preview-cell.active { background-color: #ffc966; }
.preview-cell.accent { background-color: #f79992; }
.rhythm-controls { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 20px; }
.random-rhythm-toggle, .rhythm-accent-toggle { display: flex; align-items: center; gap: 5px; }
#random-rhythm-checkbox, #rhythm-accent-checkbox { width: 18px; height: 18px; cursor: pointer; }
.random-rhythm-toggle label, .rhythm-accent-toggle label { font-size: 1.2em; cursor: pointer; user-select: none; }
#start-stop-btn { background-color: #4CAF50; color: white; border: none; padding: 15px 0; text-align: center; width: 100%; font-size: 16px; margin-top: 20px; cursor: pointer; border-radius: 5px; }
.module-toggles { display: flex; gap: 10px; margin-top: 10px; }
#toggle-rhythm-panel-btn, #toggle-chord-panel-btn { flex: 1; background-color: #555; color: white; border: none; padding: 12px 0; text-align: center; font-size: 16px; cursor: pointer; border-radius: 5px; transition: opacity 0.1s; }
#start-stop-btn:hover, #toggle-rhythm-panel-btn:hover, #toggle-chord-panel-btn:hover { opacity: 0.9; }
.chord-module-footer, .rhythm-module-footer { margin-top: auto; padding-top: 20px; font-size: 0.7em; color: #888; }
.toaster-popup { position: fixed; top: 30px; left: 50%; transform: translateX(-50%); background-color: rgba(0, 0, 0, 0.75); color: white; padding: 12px 20px; border-radius: 25px; font-size: 0.9em; z-index: 1000; animation: fade-in-out-top 2.2s ease-in-out forwards; pointer-events: none; }
@keyframes fade-in-out-top { 0% { opacity: 0; transform: translate(-50%, -10px); } 10% { opacity: 1; transform: translate(-50%, 0); } 90% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -10px); } }
@media (max-width: 1100px) {
    .app-container { grid-template-columns: 1fr; justify-items: center; align-items: center; }
    .rhythm-module, .main-metronome, .chord-module { grid-column: 1; justify-self: auto; }
    .metronome { width: 100%; max-width: 450px; }
}