/* layout.css — 전체 컨테이너 및 5개 ZONE 레이아웃 설계 */
html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    height: 100dvh;   /* Dynamic viewport height */
    width: 100%;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-ui);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 메인 프레임 컨테이너 — 최대 가로 길이를 제한하여 모바일 비율 유지 */
.metronome-container {
    width: 100%;
    max-width: 430px;
    height: 100%;
    height: 100dvh;
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    overflow-y: auto; /* 작은 세로 화면에서 스크롤 가능하도록 설정 */
    scrollbar-width: none;  /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

.metronome-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* ZONE A: 헤더바 */
.app-header {
    height: 6vh;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-subtle);
    background-color: rgba(20, 20, 20, 0.4);
}

.back-btn {
    color: var(--text-muted);
    font-size: 1.1rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--min-touch);
    height: var(--min-touch);
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
}

.back-btn:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05);
}

.app-title {
    font-weight: 800;
    letter-spacing: 1px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #fff 40%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-version {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ZONE B: LCD 디스플레이 패널 */
.lcd-panel {
    height: 18vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    gap: 8px;
    background-color: rgba(10, 10, 10, 0.3);
}

/* ZONE C: 메인 컨트롤 영역 */
.controls-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    padding: 16px;
    gap: 12px;
    background-color: rgba(15, 15, 15, 0.2);
}

/* ZONE D: 볼륨 노브 패널 */
.volume-panel {
    height: 22vh;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    background-color: rgba(10, 10, 10, 0.4);
}

/* ZONE E: 액션 버튼 바 */
.action-panel {
    height: 13vh;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-top: 1px solid var(--border-subtle);
    background-color: rgba(5, 5, 5, 0.5);
    gap: 12px;
}

/* 유틸리티 클래스 */
.hidden {
    display: none !important;
}

/* ── 미디어 쿼리: 세로 높이가 작은 모바일 기기 대응 (Galaxy 및 인앱 브라우저 최적화) ── */
@media (max-height: 840px) {
    :root {
        --dial-size: min(80px, 18vw); /* 다이얼 사이즈 축소 */
        --knob-size: min(34px, 8vw);  /* 하단 볼륨 노브 사이즈 축소 */
    }
    
    .app-header {
        height: 5vh;
        min-height: 38px;
    }
    
    .lcd-panel {
        height: auto;
        min-height: 110px;
        flex-shrink: 0;
        padding: 6px 12px;
        gap: 2px;
    }
    
    .controls-panel {
        padding: 6px 10px;
        gap: 4px;
        justify-content: flex-start !important; /* space-evenly 분배로 인한 갤럭시 겹침 버그 해결 */
    }
    
    .volume-panel {
        height: 14vh;
        padding: 4px 12px;
    }
    
    .action-panel {
        height: 10vh;
        min-height: 60px;
    }

    .dial-label {
        font-size: 0.65rem;
        margin-bottom: 4px;
    }

    .mode-switch {
        width: 140px;
        height: 26px;
        border-radius: 13px;
    }

    .mode-switch-thumb {
        width: 68px;
        height: 22px;
        border-radius: 11px;
    }

    .mode-switch.advanced .mode-switch-thumb {
        left: 70px;
    }

    .mode-switch-label {
        font-size: 0.62rem;
    }

    .mode-btn {
        padding: 4px 0;
        font-size: 0.65rem;
    }

    .action-btn {
        padding: 5px 0;
        font-size: 0.7rem;
    }

    .rhythm-switch-section {
        padding: 4px 6px;
    }

    .rhythm-slider-wrapper {
        height: 44px;
    }

    .rhythm-slider {
        width: 38px;
    }

    .control-btn {
        padding: 5px 10px;
        font-size: 0.65rem;
    }

    .prog-btns .control-btn {
        padding: 3px 10px;
        font-size: 0.58rem;
    }

    .btn-start-tap {
        height: 42px;
        font-size: 0.85rem;
    }

    .timbre-editor-panel, .variation-editor-panel {
        height: 80px;
        padding: 4px 8px;
    }

    .timbre-select-col select {
        font-size: 0.6rem;
        padding: 2px 1px;
    }

    .var-row {
        padding: 4px 6px;
    }

    .var-name {
        font-size: 0.68rem;
    }

    .var-details {
        font-size: 0.6rem;
    }
}
