/* 🎨 全体的なデザインの改良 (前回の提案から維持) */
body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #e9eef7; /* 淡い青みがかった背景 */
    color: #1a1a1a;
    line-height: 1.6;
    min-height: 100vh;
}
.container {
    max-width: 800px;
    margin: 40px auto;
    background-color: #ffffff;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15); /* より強いシャドウ */
    border-radius: 20px;
    overflow: hidden;
}
header {
    background-color: #1565C0; /* Darker Primary Blue */
    color: white;
    padding: 25px 20px;
    text-align: center;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}
h1 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 800;
}

/* 🎧 プレイヤーエリア */
.player-area {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 25px;
    background-color: #f7f9fc;
    border-bottom: 2px solid #e0e0e0;
}
#player-info-text-area {
    display: flex;
    align-items: center;
    width: 100%;
    cursor: pointer;
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 15px;
    transition: background-color 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    background-color: #ffffff;
}
#player-info-text-area:hover {
    background-color: #e8f4ff;
}
#current-artwork {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 12px;
    margin-right: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}
.current-text-info {
    flex-grow: 1;
    min-width: 0;
}
#current-title {
    font-size: 1.6em;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 4px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#current-artist {
    font-size: 1.1em;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 📶 プログレスバー */
.progress-container {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 5px;
}
#progress-bar {
    width: 0;
    height: 100%;
    background: #2196F3;
    border-radius: 4px;
    transition: width 0.1s linear;
}
.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 15px;
    margin-top: 5px;
    width: 100%;
}

/* 🎛️ コントロール */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    padding: 15px 0 10px;
}
.control-btn {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #444;
    padding: 8px;
    transition: transform 0.1s, color 0.2s;
    line-height: 1;
    border-radius: 50%;
}
.control-btn:hover {
    color: #2196F3;
    transform: scale(1.05);
}
#main-play-btn {
    font-size: 3.8em; /* メインボタンを大きく */
    color: #2196F3;
    box-shadow: 0 4px 10px rgba(33, 150, 243, 0.3);
}
#main-play-btn:hover {
    color: #1565C0;
}

/* 速度調整コントロール */
.speed-control-container {
    position: relative;
    display: flex;
    align-items: center;
    font-size: 1.5em;
}
#speed-btn {
    font-size: 1em;
    color: #666;
    background-color: #eee;
    border-radius: 6px;
    padding: 5px 10px;
    font-weight: 600;
    transition: background-color 0.2s;
    cursor: pointer;
}
#speed-btn:hover {
    background-color: #ddd;
    color: #1a1a1a;
}

.speed-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    list-style: none;
    padding: 10px;
    margin: 0 0 10px 0;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    z-index: 50;
}
.speed-menu.open {
    display: block;
}
.speed-menu li {
    margin: 5px 0;
}
.speed-menu button {
    background: none;
    border: none;
    padding: 8px 15px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 1em;
    border-radius: 4px;
    transition: background-color 0.1s;
}
.speed-menu button:hover {
    background-color: #f0f0f0;
}
.speed-menu button.active {
    background-color: #2196F3;
    color: white;
    font-weight: 700;
}

/* シャッフル・リピート */
#shuffle-btn, #repeat-btn {
    font-size: 1.8em;
    color: #666;
    margin: 0 5px;
}
#shuffle-btn.active {
    color: #FFC107; /* Amber for active shuffle */
}
#repeat-btn.repeat-list, #repeat-btn.repeat-one {
    color: #2196F3;
}

/* ボリュームコントロール */
.volume-control {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 25px 25px;
    width: 100%;
    box-sizing: border-box;
    border-top: 1px solid #e0e0e0;
}
#volume-slider {
    flex-grow: 1;
    height: 6px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: #d0d0d0;
    border-radius: 3px;
}
#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #2196F3;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

/* 📜 プレイリストエリア */
.song-list-container {
    padding: 0 25px 25px;
}
.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    margin-bottom: 15px;
}
h2 {
    font-size: 1.6em;
    color: #1a1a1a;
    border-bottom: 3px solid #2196F3;
    padding-bottom: 5px;
    margin: 0; 
    flex-grow: 1;
    font-weight: 600;
}
#sort-mode-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    border-radius: 20px;
    font-size: 0.9em;
    margin-left: 10px;
    transition: background 0.2s;
    font-weight: 500;
}
#sort-mode-btn.active {
    background: #ffc107;
    color: #1a1a1a;
}
#search-input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1em;
    transition: border-color 0.3s, box-shadow 0.3s;
}
#search-input:focus {
    border-color: #2196F3;
    box-shadow: 0 0 5px rgba(33, 150, 243, 0.5);
    outline: none;
}

/* 🎵 楽曲リストアイテム */
#song-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.song-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 10px; 
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08); 
    transition: background-color 0.2s, transform 0.1s;
    position: relative;
    cursor: default; 
    border: 1px solid transparent;
}
.song-item:not(.playing):hover {
    background-color: #f5faff;
    transform: translateY(-2px);
}
.song-item.playing {
    background-color: #e8f4ff;
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.3);
    border: 1px solid #2196F3;
}

.song-item-artwork {
    width: 55px;
    height: 55px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 15px;
    flex-shrink: 0;
}

.song-info {
    flex-grow: 1;
    cursor: pointer;
    min-width: 0;
    padding-right: 10px;
}
.song-info div {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.1em;
    font-weight: 600;
    color: #1a1a1a;
}
.song-info small {
    color: #666;
    display: block;
    margin-top: 2px;
    font-size: 0.9em;
}

.play-toggle-btn {
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    line-height: 1;
    font-size: 1.1em;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 10px;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.play-toggle-btn:hover {
    background: #0d6efd;
    transform: scale(1.05);
}

/* ⚙️ 並び替えモードのスタイル */
.drag-handle {
    font-size: 1.6em;
    color: #ccc;
    margin-right: 10px;
    padding: 0 5px;
    cursor: default;
    opacity: 0; 
    transition: opacity 0.2s, cursor 0.2s;
    flex-shrink: 0;
}
.song-item.is-sorting-mode .drag-handle {
    opacity: 1;
    color: #4a4a4a;
    cursor: grab; 
}
.song-item.is-sorting-mode .song-info {
    cursor: default;
}
.song-item.is-sorting-mode .play-toggle-btn,
.song-item.is-sorting-mode .hide-btn {
    display: none;
}

/* ✖️ 非表示ボタン */
.hide-btn {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.1em;
    cursor: pointer;
    margin-left: 15px;
    flex-shrink: 0;
    opacity: 0.7;
}
.hide-btn:hover {
    opacity: 1;
}

/* 🌑 モーダル (フルスクリーン) */
.modal {
    display: none; 
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: #1a1a1a;
    color: white;
}
.modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    box-sizing: border-box;
}
.modal-artwork {
    width: 90%;
    max-width: 450px;
    height: auto;
    object-fit: cover;
    border-radius: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    margin-bottom: 40px;
}
.modal-title {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    word-break: break-word;
}
.modal-artist {
    font-size: 1.5em;
    color: #999;
    margin-bottom: 50px;
    text-align: center;
}
/* 💡 歌詞表示エリアとLRC同期用スタイル */
.modal-lyrics {
    white-space: pre-wrap;
    text-align: center;
    max-height: 35vh; 
    overflow-y: auto;
    font-size: 1.2em; 
    color: #ccc;
    margin-top: 30px;
    margin-bottom: 60px;
    padding: 20px;
    max-width: 90%;
    border: 1px solid #444;
    border-radius: 15px;
    background-color: rgba(0, 0, 0, 0.4);
    line-height: 1.6;
    position: relative; /* スクロールコンテナ */
}
.modal-lyrics p {
    padding: 4px 0;
    margin: 0;
    opacity: 0.6;
    transition: opacity 0.3s, color 0.3s, transform 0.3s;
}
.modal-lyrics p.highlight {
    opacity: 1;
    color: #2196F3; /* ハイライトカラー */
    font-weight: bold;
    transform: scale(1.1); /* ハイライト行を少し拡大 */
}
/* スクロールバーはブラウザ依存のため省略 */

.close-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 50px;
    cursor: pointer;
    opacity: 0.8;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
}
.close-btn:hover {
    opacity: 1;
}

/* その他 */
.next-songs-info {
    margin-top: 20px;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    border-radius: 10px;
    font-size: 0.95em;
    color: #6c757d;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}
.hidden-toggle-area {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

/* 💡 キャッシュステータスエリアのスタイル */
.cache-status-area {
    width: 100%;
    padding: 15px 25px;
    box-sizing: border-box;
    background-color: #e0f7fa;
    border-top: 1px solid #b2ebf2;
    text-align: center;
}
#cache-btn {
    background-color: #00bcd4;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background-color 0.2s;
}
#cache-btn:hover:not(:disabled) {
    background-color: #0097a7;
}
#cache-btn:disabled {
    background-color: #9e9e9e;
    cursor: not-allowed;
}
#cache-progress {
    margin: 10px auto 0;
    width: 80%;
    background-color: #cfd8dc;
    overflow: hidden;
}
#cache-bar {
    background: #4CAF50 !important; /* キャッシュ用プログレスバーの色 */
    transition: width 0.3s ease;
}
#cache-text {
    margin-top: 8px;
    font-size: 0.9em;
    color: #333;
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
    .container {
        margin: 0;
        border-radius: 0;
    }
    header {
        border-radius: 0;
    }
    .player-area, .song-list-container, .volume-control {
        padding-left: 15px;
        padding-right: 15px;
    }
    .controls {
        gap: 15px;
    }
    .control-btn {
        font-size: 1.8em;
    }
    #main-play-btn {
        font-size: 3.5em;
    }
    #player-info-text-area {
        padding: 10px;
    }
    #current-artwork {
        width: 60px;
        height: 60px;
        margin-right: 15px;
    }
    #current-title {
        font-size: 1.3em;
    }
    #current-artist {
        font-size: 1em;
    }
}