:root {
    --bg: #14151b;
    --bg-glow: #221f3a;
    --card: #1d1e26;
    --card-2: #262833;
    --line: rgba(255, 255, 255, 0.09);
    --text: #f2f2f7;
    --muted: rgba(242, 242, 247, 0.62);
    --accent: #8b7cf6;
    --accent-hover: #9d90f8;
    --accent-soft: #b4a9ff;
    --danger: #ff7b7b;
    --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
    background: radial-gradient(1200px 600px at 50% -10%, var(--bg-glow), var(--bg) 70%) fixed, var(--bg);
    color: var(--text);
    font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#app { max-width: 880px; margin: 0 auto; padding: 20px 16px 28px; }

.topbar { display: flex; align-items: center; padding: 4px 4px 16px; }
.brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo {
    width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
    background: linear-gradient(135deg, #8b7cf6, #5b8cff); font-weight: 800; color: #fff;
}
.brand-name { font-size: 20px; font-weight: 600; }
.badge {
    font-size: 12px; font-weight: 600; color: var(--accent-soft); padding: 3px 10px 4px; border-radius: 12px;
    background: rgba(139, 124, 246, 0.2); border: 1px solid rgba(139, 124, 246, 0.4);
}

.card {
    background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.file-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.file-info { min-width: 0; }
.title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.details { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn {
    display: inline-flex; align-items: center; gap: 8px; flex: none; cursor: pointer;
    background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 14px; font: inherit; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #30323f; border-color: rgba(255, 255, 255, 0.18); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, .play:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.notice {
    margin: 0 0 14px; padding: 10px 14px; border-radius: 8px; font-size: 13.5px;
    background: rgba(91, 140, 255, 0.14); border: 1px solid rgba(91, 140, 255, 0.35);
}
.notice.error { background: rgba(255, 123, 123, 0.13); border-color: rgba(255, 123, 123, 0.4); color: #ffd3d3; }

.stage { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; align-items: start; margin: 6px 0 18px; }
.radar-wrap { background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
#radar { display: block; max-width: 100%; height: auto; }

.listing h2 { margin: 6px 0 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); }
.active { display: flex; flex-direction: column; gap: 10px; min-height: 250px; }
.row { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 10px; align-items: start; transition: opacity 0.2s; }
.row .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.row .name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .where { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .level { height: 3px; border-radius: 2px; margin-top: 4px; min-width: 4px; max-width: 100%; }
.row.empty { grid-template-columns: 1fr; color: var(--muted); font-size: 13.5px; }

.transport { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.play {
    position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--card-2); color: var(--text); display: grid; place-items: center; cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.play:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.play:active:not(:disabled) { transform: scale(0.96); }
.play:disabled { opacity: 0.45; cursor: default; }
.play .ring {
    position: absolute; inset: -4px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--accent-soft);
    opacity: 0; animation: spin 0.9s linear infinite; pointer-events: none;
}
.play.buffering .ring { opacity: 1; }

#seek { flex: 1 1 200px; min-width: 120px; }
.time { font-size: 13px; min-width: 96px; text-align: right; font-variant-numeric: tabular-nums; }

input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; height: 24px; cursor: pointer; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.2); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.2); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: var(--accent-soft); border: 0; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent-soft); border: 0; }
input[type="range"]:disabled { opacity: 0.45; cursor: default; }
input[type="range"]:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; border-radius: 4px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 40px; height: 20px; border-radius: 10px; background: #4a4d5c; position: relative; transition: background 0.15s; flex: none; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.switch input:disabled ~ * { opacity: 0.5; }

.volume { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.volume input { width: 90px; }

.hint { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); }

.foot { margin-top: 16px; text-align: center; font-size: 12px; color: var(--muted); }
.foot a { color: var(--accent-soft); }

.overlay {
    position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
    background: rgba(10, 10, 16, 0.72); backdrop-filter: blur(4px);
}
.overlay[hidden] { display: none; }
.loading-box { width: min(420px, 86vw); text-align: center; }
.loading-text { margin: 14px 0 12px; font-size: 14px; }
.bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.spinner { width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.15); border-top-color: var(--accent-soft); animation: spin 0.9s linear infinite; }
.drop { border: 3px dashed var(--accent); margin: 14px; font-size: 20px; font-weight: 600; pointer-events: none; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
    .stage { grid-template-columns: 1fr; }
    /* Di layar HP kontrol putar tetap terlihat di bawah saat daftar suara di-scroll. */
    .transport { position: sticky; bottom: 0; z-index: 5; background: var(--card); padding: 12px 0 8px; margin-top: 4px; border-top: 1px solid var(--line); }
    .radar-wrap { justify-self: center; }
    .active { min-height: 0; }
    .time { text-align: left; }
}

@media (max-width: 520px) {
    .card { padding: 16px; }
    .file-row { flex-wrap: wrap; }
    .volume input { width: 70px; }
}

@media (prefers-reduced-motion: reduce) {
    .spinner, .play .ring { animation-duration: 3s; }
    * { transition: none !important; }
}
