/* --- 1. 전체 테마 --- */
* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    background: #0d1117;
    background-image: radial-gradient(circle at 50% 0%, #161b22 0%, #000000 80%);
    color: #e6edf3;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    margin: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; user-select: none;
}

/* --- 2. 플레이어 영역 --- */
#player-wrapper {
    width: 100%;
    background: transparent;
    position: relative;
    padding-bottom: 50%;
    flex-shrink: 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    z-index: 10;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: padding-bottom 0.3s ease;
}

#album-art-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover; opacity: 0.25; filter: blur(25px); transform: scale(1.2); z-index: 1;
}

#album-art-center {
    position: absolute;
    top: 8%; left: 50%; transform: translateX(-50%);
    width: auto; height: 66%; aspect-ratio: 1/1;
    border-radius: 50%; object-fit: cover;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.05), 0 0 40px rgba(0,242,254,0.15);
    z-index: 2;
    animation: spin 15s linear infinite;
    animation-play-state: paused;
}
@keyframes spin { 100% { transform: translateX(-50%) rotate(360deg); } }

/* 곡 정보 (앨범아트 아래) */
#track-info {
    position: absolute;
    bottom: 38px; left: 0; right: 0;
    text-align: center; z-index: 3; padding: 0 16px;
}
#track-title {
    font-size: 14px; font-weight: 700; color: #e6edf3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}
#track-channel {
    font-size: 12px; color: rgba(255,255,255,0.45); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 진행 바 */
#progress-wrap {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 4; padding: 0 12px 6px;
}
#progress-bar {
    position: relative;
    width: 100%; height: 4px; background: rgba(255,255,255,0.1); border-radius: 4px;
    cursor: pointer; margin-bottom: 4px; transition: height 0.2s ease;
    touch-action: none;
}
#progress-bar:hover, #progress-bar.dragging {
    height: 6px;
}
#progress-fill {
    height: 100%; width: 0%; background: linear-gradient(90deg, #00f2fe, #4facfe);
    border-radius: 4px; transition: width 0.2s linear; pointer-events: none;
}
#progress-bar.dragging #progress-fill {
    transition: none !important;
}
#progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px rgba(0, 242, 254, 0.6), 0 0 1px rgba(255,255,255,0.8);
    pointer-events: none;
    opacity: 0.7;
    transition: opacity 0.2s ease, width 0.2s ease, height 0.2s ease, left 0.2s linear;
}
#progress-bar.dragging #progress-handle {
    transition: opacity 0.2s ease, width 0.2s ease, height 0.2s ease, left 0s !important;
}
#progress-bar:hover #progress-handle, #progress-bar.dragging #progress-handle {
    opacity: 1;
    width: 22px;
    height: 22px;
    box-shadow: 0 0 12px rgba(0, 242, 254, 1.0), 0 0 3px rgba(255,255,255,1.0);
}
#time-display {
    display: flex; justify-content: space-between;
    font-size: 10px; color: rgba(255,255,255,0.3);
}

/* --- 3. 컨트롤 패널 --- */
.control-panel {
    background: rgba(13,17,23,0.6); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255,255,255,0.05); border-radius: 0 0 25px 25px;
    padding: 15px 15px; flex-shrink: 0; margin-bottom: 10px;
}
.playback-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding: 0 10px; }
.btn-ctrl { background: none; border: none; color: rgba(255,255,255,0.8); cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; }
.btn-ctrl:active { transform: scale(0.9); color: #fff; }
#playPauseBtn {
    width: 65px; height: 65px; border-radius: 50%;
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    color: #000; font-size: 26px; box-shadow: 0 8px 20px rgba(0,242,254,0.3); text-indent: 4px;
}
.track-btn { font-size: 28px; color: #fff; }
.seek-btn { font-size: 13px; color: rgba(255,255,255,0.5); font-weight: 600; flex-direction: column; gap: 4px; }
.seek-icon { font-size: 20px; }

.toolbar { display: flex; gap: 6px; align-items: center; }

/* 볼륨: 스피커 아이콘 탭 → 세로 슬라이더 팝업 (가로 진행바와 안 헷갈리게) */
.vol-wrap { position: relative; flex-shrink: 0; display: flex; }
.vol-popup { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 9998;
    background: rgba(22,27,34,0.98); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
    padding: 12px 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.6); display: flex; justify-content: center; }
.vol-slider-vert { writing-mode: vertical-lr; direction: rtl; width: 8px; height: 110px; accent-color: #00f2fe; cursor: pointer; }
#loopBtn, #settingsBtn, #volBtn {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
    width: 38px; height: 38px; border-radius: 12px; font-size: 16px;
    color: rgba(255,255,255,0.4); cursor: pointer; transition: 0.2s;
}
#loopBtn.active { color: #00f2fe; border-color: rgba(0,242,254,0.5); background: rgba(0,242,254,0.1); }
#loopBtn.one    { color: #4facfe; border-color: rgba(79,172,254,0.5); background: rgba(79,172,254,0.1); }
#settingsBtn:active { color: #fff; border-color: #fff; }

.tabs { flex: 1; min-width: 0; display: flex; background: rgba(0,0,0,0.4); border-radius: 14px; padding: 4px; border: 1px solid rgba(255,255,255,0.03); }
.tab-btn { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 6px; border: none; background: none; color: rgba(255,255,255,0.4); font-size: 12px; font-weight: 500; border-radius: 12px; cursor: pointer; transition: all 0.3s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-yt-ico { width: 16px; height: 16px; flex-shrink: 0; }
.tab-btn.active { background: rgba(255,255,255,0.08); color: #00f2fe; font-weight: 700; box-shadow: 0 2px 10px rgba(0,0,0,0.3); }

/* --- 4. 컨텐츠 영역 --- */
.content-area { flex: 1; overflow-y: auto; position: relative; padding: 0 15px 80px 15px; }

.folder-chips { display: flex; overflow-x: auto; gap: 8px; padding: 0 0 10px 0; margin-bottom: 10px; scrollbar-width: none; }
.folder-chips::-webkit-scrollbar { display: none; }
.chip { padding: 8px 16px; border-radius: 20px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.05); color: rgba(255,255,255,0.6); font-size: 14px; white-space: nowrap; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.chip.active { background: rgba(0,242,254,0.1); border: 1px solid #00f2fe; color: #00f2fe; font-weight: bold; box-shadow: 0 0 10px rgba(0,242,254,0.1); }
.chip .del-folder { font-size: 10px; background: rgba(0,0,0,0.5); border-radius: 50%; width: 18px; height: 18px; display: flex; justify-content: center; align-items: center; color: #fff; }

.search-box { display: flex; gap: 10px; margin-bottom: 20px; position: sticky; top: 0; background: rgba(13,17,23,0.95); backdrop-filter: blur(10px); z-index: 5; padding: 15px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
#searchInput { flex: 1; padding: 14px 20px; border-radius: 30px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.3); color: white; font-size: 15px; }
#searchInput:focus { border-color: #00f2fe; background: rgba(0,0,0,0.5); }
#searchBtn { background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%); color: #000; border: none; padding: 0 22px; border-radius: 30px; font-weight: bold; font-size: 14px; cursor: pointer; box-shadow: 0 4px 15px rgba(0,242,254,0.25); white-space: nowrap; flex-shrink: 0; }

.video-item { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.03); padding: 10px; border-radius: 16px; transition: transform 0.1s, background 0.2s, border 0.2s; }
.video-item.playing { border: 1px solid rgba(0,242,254,0.4); background: linear-gradient(90deg, rgba(0,242,254,0.08) 0%, rgba(255,255,255,0) 100%); }

.thumb { width: 70px; height: 40px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.info { flex: 1; overflow: hidden; }
.title {
    font-size: 14px; margin-bottom: 4px; color: #e6edf3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    white-space: normal; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.channel { font-size: 12px; color: rgba(255,255,255,0.4); }

.action-btn { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.05); color: #e6edf3; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: pointer; flex-shrink: 0; }
.add-btn { color: #00f2fe; width: 32px; height: 32px; font-size: 18px; border-color: rgba(0,242,254,0.3); background: rgba(0,242,254,0.05); }
.del-btn { color: #ff5555; }
.order-btn { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); color: rgba(255,255,255,0.55); width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; cursor: pointer; flex-shrink: 0; transition: all 0.2s; }
.order-btn.active { background: #00f2fe; color: #000; border-color: #00f2fe; box-shadow: 0 0 12px rgba(0,242,254,0.55); }
.video-item.picking { border: 1px solid #00f2fe; background: rgba(0,242,254,0.12); box-shadow: 0 0 18px rgba(0,242,254,0.22); }
.video-item.drop-target { cursor: pointer; }
.video-item.drop-target:active { background: rgba(0,242,254,0.08); border-color: rgba(0,242,254,0.4); }

/* 다운로드 상태 뱃지 */
.dl-badge {
    font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 20px;
    white-space: nowrap; flex-shrink: 0; letter-spacing: 0.3px;
}
.dl-badge.downloading { background: rgba(255,170,0,0.15); color: #ffaa00; border: 1px solid rgba(255,170,0,0.3); animation: badge-pulse 1.5s ease-in-out infinite; }
.dl-badge.ready       { display: none; }
.dl-badge.error       { background: rgba(248,81,73,0.15); color: #f85149; border: 1px solid rgba(248,81,73,0.3); }
.dl-badge.not_found   { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.35); border: 1px solid rgba(255,255,255,0.1); }
.dl-badge.unknown     { background: rgba(79,172,254,0.1); color: #79c0ff; border: 1px solid rgba(79,172,254,0.3); }
@keyframes badge-pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.empty-msg { text-align: center; margin-top: 50px; color: rgba(255,255,255,0.3); font-size: 14px; line-height: 1.6; }
.hidden { display: none !important; }

#pwaInstallBtn { display: none; width: calc(100% - 40px); margin: 10px auto 20px auto; padding: 16px; color: #000; font-weight: 800; font-size: 16px; border: none; border-radius: 30px; cursor: pointer; background: linear-gradient(-45deg, #00f2fe, #4facfe, #00c6ff, #0072ff); background-size: 400% 400%; box-shadow: 0 8px 20px rgba(0,242,254,0.3); animation: gradientBG 10s ease infinite, pulseBtn 2s infinite; }
@keyframes gradientBG { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
@keyframes pulseBtn  { 0%,100%{transform:scale(1);box-shadow:0 8px 20px rgba(0,242,254,0.3)} 50%{transform:scale(1.03);box-shadow:0 12px 25px rgba(0,242,254,0.5)} }

#toast { visibility: hidden; min-width: 220px; background: rgba(30,35,45,0.95); border: 1px solid rgba(255,255,255,0.1); color: #fff; text-align: center; font-weight: 500; border-radius: 50px; padding: 14px 20px; position: fixed; z-index: 100; left: 50%; bottom: 40px; transform: translateX(-50%); font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); }
#toast.show { visibility: visible; animation: fadein 0.5s, fadeout 0.5s 2.5s; }
@keyframes fadein  { from{bottom:10px;opacity:0} to{bottom:40px;opacity:1} }
@keyframes fadeout { from{bottom:40px;opacity:1} to{bottom:10px;opacity:0} }

#move-modal, #settings-modal, #restore-modal, #save-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.modal-bg { position: absolute; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); }
.modal-content { position: relative; background: rgba(22,27,34,0.95); padding: 25px 20px; border-radius: 20px; width: 80%; max-width: 320px; box-shadow: 0 20px 40px rgba(0,0,0,0.8); border: 1px solid rgba(255,255,255,0.08); max-height: 80vh; overflow-y: auto; }
.modal-content h3 { margin-top: 0; color: #fff; text-align: center; margin-bottom: 20px; font-size: 18px; font-weight: 600; }
.move-folder-item { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.02); padding: 15px; border-radius: 12px; margin-bottom: 8px; text-align: center; font-size: 15px; cursor: pointer; transition: all 0.2s; color: #e6edf3; }
.move-folder-item:active { background: rgba(0,242,254,0.1); border-color: #00f2fe; color: #00f2fe; }
.restore-file-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; }
.restore-file-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.restore-file-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.restore-file-date { font-size: 11px; color: rgba(255,255,255,0.3); }
.restore-file-actions { flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.restore-action-btn { border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.06); color: #e6edf3; border-radius: 8px; padding: 7px 8px; font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.restore-action-btn.danger { color: #ff7b72; border-color: rgba(255,123,114,0.35); background: rgba(255,123,114,0.08); }
.restore-action-btn:active { transform: scale(0.95); }
.close-btn { width: 100%; padding: 14px; background: none; border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; color: rgba(255,255,255,0.5); margin-top: 10px; cursor: pointer; font-size: 15px; font-weight: bold; transition: 0.2s; }
.close-btn:active { background: rgba(255,255,255,0.1); }
.menu-btn { width: 100%; padding: 15px; border: none; border-radius: 12px; color: white; font-size: 15px; font-weight: bold; cursor: pointer; transition: transform 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; }
.menu-btn:active { transform: scale(0.95); }

/* 저장 모달 */
.save-newname-row { display: flex; gap: 8px; margin: 6px 0 14px; }
.save-newname-row input { flex: 1; min-width: 0; padding: 12px 16px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.3); color: #fff; font-size: 14px; }
.save-newname-row input:focus { border-color: #00f2fe; background: rgba(0,0,0,0.5); }
.save-newname-row button { flex-shrink: 0; padding: 0 20px; border-radius: 12px; border: none; background: linear-gradient(135deg,#00f2fe 0%,#4facfe 100%); color: #000; font-weight: bold; font-size: 14px; cursor: pointer; }
.save-divider { text-align: center; font-size: 12px; color: rgba(255,255,255,0.35); margin: 4px 0 10px; }
.save-overwrite-tag { flex-shrink: 0; font-size: 11px; color: rgba(255,255,255,0.35); }
.app-version { margin: 14px 0 2px; color: rgba(255,255,255,0.32); font-size: 12px; line-height: 1.4; text-align: center; user-select: none; }

#update-snackbar { visibility: hidden; min-width: 250px; background: rgba(22,27,34,0.95); border: 1px solid #00f2fe; color: #fff; text-align: center; font-weight: bold; border-radius: 15px; padding: 16px; position: fixed; z-index: 99999; left: 50%; bottom: 30px; transform: translateX(-50%); font-size: 15px; box-shadow: 0 10px 30px rgba(0,242,254,0.2); cursor: pointer; transition: visibility 0s, bottom 0.5s, opacity 0.5s; opacity: 0; }
#update-snackbar.show { visibility: visible; bottom: 50px; opacity: 1; }

/* 진행바 클릭 (seek) */
#progress-bar { touch-action: none; }

/* ── PC / 와이드 스크린 레이아웃 (600px 이상) ───────────────── */
@media (min-width: 600px) {
    html { background: #000; }
    body { max-width: 500px; margin: 0 auto; box-shadow: 0 0 100px rgba(0,0,0,0.6); }
    #left-panel { display: contents; }
    #player-wrapper { padding-bottom: 80%; }
}
