:root {
    --bg: #0f1220;
    --panel: #151833;
    --panel-2: #1c2040;
    --text: #e7ebf7;
    --muted: #a8b0c8;
    --accent: #3e467a;
    --accent-2: #6b74a8;
    --danger: #ff6b6b;
    --border: #2a305a;
}

input[type="range"]::-webkit-slider-runnable-track {
    background: transparent;
}
input[type="range"]::-moz-range-track {
    background: transparent;
}

* {
    box-sizing: border-box;
}

/* 스크린리더 전용 텍스트 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.btn:focus-visible,
.upload-btn:focus-visible,
input[type="range"]:focus-visible,
.playlist li[role="button"]:focus-visible,
label.upload-btn:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    /* 배경의 블루 톤을 더 완화 */
    background: radial-gradient(1200px 800px at 20% 0%, #14172b 0%, #0f1220 60%, #0b0e18 100%);
    color: var(--text);
}

.app {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: 100vh;
    height: 100vh;
}

/* 사이드바 */
.sidebar {
    background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
    border-right: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 18px;
    margin: 0;
}

.toolbar {
    margin-left: auto;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.upload-btn {
    /* 강조색 제거 */
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.upload-btn:hover {
    background: #222742;
}
.upload-btn:active {
    background: #1e223b;
}

.btn {
    background: #1b1e32;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.btn:hover {
    background: #222742;
} /* 모든 버튼 공통 호버 */
.btn:active {
    background: #1e223b;
}

.btn.primary {
    background: var(--accent);
    color: #0a0d1c;
    border-color: transparent;
}
.btn.primary:hover {
    background: #545d91;
}
.btn.primary:active {
    background: #333a66;
}
.btn.ghost {
    background: transparent;
}

/* 툴바 버튼 아이콘/텍스트 정렬 */
.toolbar .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 10px;
}
.toolbar .icon {
    width: 16px;
    height: 16px;
}
/* 아이콘 있을 때 텍스트 숨김 */
.upload-btn.has-icon .label,
.toolbar .btn.has-icon .label {
    display: none;
}

/* 라운드 아이콘 버튼 (조작 버튼 크게) */
.btn-round {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    padding: 0;
    display: grid;
    place-items: center;
}
.controls #btn-prev.btn-round,
.controls #btn-next.btn-round {
    width: 52px;
    height: 52px;
}
.controls .btn-round .icon {
    width: 28px;
    height: 28px;
    display: block;
}
.controls #btn-prev .icon,
.controls #btn-next .icon {
    width: 22px;
    height: 22px;
}
.controls .btn-round .fallback {
    display: none;
    font-size: 24px;
    line-height: 1;
}
.controls .btn-round:not(.has-icon) .fallback {
    display: inline-block;
}
/* 재생 버튼- 상태에 따라 표시 토글 (아이콘 우선, 폴백은 JS/온에러로 보임) */
#btn-play .icon-play,
#btn-play .icon-pause,
#btn-play .fallback-pause {
    display: none;
}
#btn-play[data-state="play"] .icon-play {
    display: block;
}
#btn-play[data-state="pause"] .icon-pause {
    display: block;
}
/* 아이콘이 없을 때의 폴백 토글 */
#btn-play:not(.has-icon) .fallback-play {
    display: inline-block;
}
#btn-play:not(.has-icon)[data-state="pause"] .fallback-play {
    display: none;
}
#btn-play:not(.has-icon)[data-state="pause"] .fallback-pause {
    display: inline-block;
}

/* svg 흰색으로 처리 */
.icon {
    filter: brightness(0) invert(1);
}

/* 셔플 활성화 시 색 변경 */
#shuffle-toggle:hover {
    background: #252a4a;
}
#shuffle-toggle[aria-pressed="true"] {
    background: #2f3763;
    border-color: #6b74a8;
}
#shuffle-toggle[aria-pressed="true"]:hover {
    background: #384170;
}

/* 비활성 상태 */
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}
input[type="range"][disabled] {
    opacity: 0.5;
    pointer-events: none;
}

.playlist {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
}

.playlist li {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--muted);
    background: transparent;
}
.playlist li:last-child {
    border-bottom: none;
}
.playlist li:hover {
    background: rgba(146, 160, 220, 0.07);
    color: var(--text);
}
.playlist li.active {
    background: rgba(108, 130, 220, 0.16);
    color: var(--text);
}
.playlist li .index {
    opacity: 0.6;
}
.playlist li .name {
    flex: 1 1 auto;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.drop-hint {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    padding: 6px 4px;
}

/* 드래그 앤 드롭 시 하이라이트 */
#drop-zone.dragover {
    outline: 2px dashed var(--accent-2);
    outline-offset: -6px;
}

/* 메인 */
.main {
    display: flex;
    flex-direction: column;
    padding: 24px 28px;
    gap: 18px;
    height: 100%;
    min-height: 0;
}

/* 하단 플레이어 영역을 맨 아래로 고정 */
.player-bottom {
    margin-top: auto;
    display: grid;
    gap: 14px;
}

.now-playing .track-title {
    font-size: 20px;
    font-weight: 700;
}

.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
}
.controls-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
}
.controls-row .controls {
    grid-column: 2;
}
.controls-row .left-spacer {
    grid-column: 1;
}
.controls-row .right-slot {
    grid-column: 3;
    justify-self: end;
}
.controls-row .right-slot #volume {
    margin-right: 74px;
}
.controls .btn-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

/* 볼륨 컨트롤 */
.volume {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
}
.volume .btn-round {
    width: 44px;
    height: 44px;
}
.volume .btn-round .icon {
    width: 18px;
    height: 18px;
    display: block;
}
.volume .btn-round .fallback {
    display: none;
}
.volume .btn-round:not(.has-icon) .fallback {
    display: inline-block;
    font-size: 20px;
}
#volume {
    width: 240px;
    max-width: 60vw;
}

.progress {
    display: grid;
    grid-template-columns: 60px 1fr 60px;
    align-items: center;
    gap: 12px;
}

.time {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 999px;
    outline: none;
    --range-pct: 0%;
    --range-accent: var(--accent-2);
    --range-rest: #1a1f3d;
    background: linear-gradient(
        to right,
        var(--range-accent) 0%,
        var(--range-accent) var(--range-pct),
        var(--range-rest) var(--range-pct),
        var(--range-rest) 100%
    );
}
/* WebKit thumb: 기본은 숨김, 호버/포커스/액티브 시 표시 */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 16px;
    width: 16px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(108, 142, 255, 0.25);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s ease;
}
input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:active::-webkit-slider-thumb,
input[type="range"]:focus-visible::-webkit-slider-thumb {
    opacity: 1;
}
/* Firefox thumb */
input[type="range"]::-moz-range-thumb {
    height: 16px;
    width: 16px;
    background: var(--accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s ease;
}
input[type="range"]:hover::-moz-range-thumb,
input[type="range"]:active::-moz-range-thumb,
input[type="range"]:focus-visible::-moz-range-thumb {
    opacity: 1;
}
/* 비활성화 시 더 연한 톤으로 */
input[type="range"][disabled] {
    --range-accent: #3a4278;
    --range-rest: #141937;
}

/* 반응형 */
@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
    }
    .sidebar {
        grid-row: 2;
    }
    .main {
        grid-row: 1;
    }
}
