/* ---------- 9.6 OST画面 ---------- */
#ost-overlay {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    
    position: absolute;
    inset: 0;
    z-index: 110;

    display: flex; /* JSで制御するがCSSでも基本構造を定義 */
    flex-direction: column;
    align-items: center;
    /* ★重要：中身を「ヘッダー・パネル・ボタン」の順で等間隔に配置 */
    justify-content: space-between; 
    box-sizing: border-box;
    padding: 2vh 0;
}

#ost-panel {
    position: relative;
    z-index: 2;
    width: min(92vw, 560px);
    padding: 16px;
    border-radius: 3px;
    border: 1px solid rgba(120,255,255,0.18);
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);

    /* ★重要設定：はみ出し防止の核 */
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    /* 画面中央付近に配置しつつ、最大高さを厳しく制限 */
    margin: auto 0;
    max-height: calc(100vh - 200px); 
    overflow: hidden; /* パネル自体からは絶対にはみ出させない */
}

#ost-scroll-container {
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    /* ★重要：他の要素（コントロール）が表示されたら、ここを縮ませる */
    flex: 1 1 auto; 
    min-height: 100px; /* 最低限のリスト表示領域を確保 */
    margin: 0;
    padding-right: 4px;
}



#btn-back {
    /* ★重要：オーバーレイ(親)の justify-content: space-between により、
       パネルのすぐ下に配置される。余白はここで調整 */
    margin-top: 10px;
    margin-bottom: 5px;
    flex-shrink: 0; 
}

#ost-scroll-container::-webkit-scrollbar {
    width: 6px;
}

#ost-scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 255, 255, 0.05);
    border-radius: 3px;
}

#ost-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.5);
    border-radius: 3px;
}

#ost-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #0ff;
}

.track-item {
    padding: calc(14px * var(--ui-scale, 1)) calc(18px * var(--ui-scale, 1));
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: #9bb6c2;
    text-align: center;
    font-size: calc(14px * var(--ui-scale, 1));
    box-sizing: border-box;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        transform 0.16s ease;
}

.track-item:hover {
    color: #d8f8ff;
    background: rgba(0,255,255,0.04);
}

.track-item.playing {
    color: #0ff;
    border-color: rgba(0,255,255,0.55);
    text-shadow: 0 0 10px #0ff;
    background: rgba(0, 255, 255, 0.08);
}

#ost-controls {
    display: none;
    width: 100%;
    margin-top: 14px;
    flex-direction: column;
    align-items: center;
}

#ost-now-playing {
    color: #d8ffff;
    font-size: calc(14px * var(--ui-scale, 1));
    margin-bottom: 10px;
    text-shadow: 0 0 8px rgba(0,255,255,0.18);
    text-align: center;
}

#ost-progress-row {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
}

#ost-time-current,
#ost-time-total {
    color: #9aa8b2;
    font-size: calc(12px * var(--ui-scale, 1));
    width: 40px;
}

#ost-time-current {
    text-align: right;
}

#ost-progress-bar {
    flex: 1;
    height: 10px;
    background: rgba(0,255,255,0.10);
    border: 1px solid rgba(0,255,255,0.55);
    border-radius: 999px;
    cursor: pointer;
    position: relative;
    box-shadow:
        0 0 10px rgba(0,255,255,0.06),
        inset 0 0 10px rgba(0,255,255,0.04);
}

#ost-progress-fill {
    width: 0%;
    height: 100%;
    background: rgba(0,255,255,0.82);
    border-radius: 999px;
    pointer-events: none;
    box-shadow: 0 0 8px #0ff;
}

#btn-back {
    margin-top: 10px;
    margin-bottom: 10px;
    /* ★追加：ボタンが押し出されないように保護 */
    flex-shrink: 0; 
}

/* =========================================
   レスポンシブ (メディアクエリ)
========================================= */

@media (orientation: portrait) {
    #ost-panel {
        width: 90vw;
        max-height: calc(100vh - 220px);
    }
}

@media (orientation: landscape) {
    #ost-panel {
        width: min(70vw, 480px);
        max-height: calc(100vh - 140px);
    }
    #btn-back {
        margin-top: 5px;
        margin-bottom: 5px;
    }
}