:root {
    --bg: #0b0e14;
    --panel: rgba(16, 21, 32, 0.78);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text: #e8ecf4;
    --text-dim: #8b94a7;
    --accent: #4cc9f0;
    --accent-2: #4361ee;
    --danger: #ef476f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
}

#map {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 0;
}

/* ---------- Glass panels ---------- */
.glass {
    background: var(--panel);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

/* ---------- Brand ---------- */
.brand {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}

.brand h1 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.brand-eq {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.brand-eq i {
    width: 3px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    animation: eq 1.1s ease-in-out infinite;
}

.brand-eq i:nth-child(1) { height: 60%; animation-delay: 0s; }
.brand-eq i:nth-child(2) { height: 100%; animation-delay: 0.25s; }
.brand-eq i:nth-child(3) { height: 45%; animation-delay: 0.5s; }
.brand-eq i:nth-child(4) { height: 80%; animation-delay: 0.12s; }

@keyframes eq {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}

/* ---------- Buttons ---------- */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 15px;
    transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover { transform: scale(1.06); }

#listToggle {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    z-index: 1000;
}

/* ---------- List panel ---------- */
#listPanel {
    position: fixed;
    top: max(68px, calc(env(safe-area-inset-top) + 56px));
    right: 12px;
    bottom: max(96px, calc(env(safe-area-inset-bottom) + 92px));
    width: min(320px, calc(100vw - 24px));
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px 8px 16px;
    border-bottom: 1px solid var(--panel-border);
}

.panel-head h2 { font-size: 14px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); }

.panel-head .icon-btn { width: 36px; height: 36px; background: transparent; }

#soundList {
    list-style: none;
    overflow-y: auto;
    padding: 6px;
    flex: 1;
}

#soundList li {
    padding: 11px 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background 0.15s ease;
}

#soundList li:hover, #soundList li.active { background: rgba(76, 201, 240, 0.12); }

#soundList .li-name { font-size: 14px; font-weight: 500; }
#soundList .li-date { font-size: 12px; color: var(--text-dim); }

/* ---------- Player ---------- */
#player {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 1200;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 14px;
    width: min(560px, calc(100vw - 24px));
    padding: 12px 14px 16px;
    overflow: hidden;
}

.play-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(67, 97, 238, 0.5);
    transition: transform 0.15s ease;
}

.play-btn:active { transform: scale(0.94); }

.player-meta { min-width: 0; }

.track-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-date { font-size: 12px; color: var(--text-dim); }

#viz { width: 150px; height: 44px; }

#progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
}

#progressFill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ---------- Sound marker (ripple) ---------- */
.sound-marker { background: transparent; border: none; }

.sound-marker .dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 10px rgba(76, 201, 240, 0.9);
}

.sound-marker .ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    border: 2px solid rgba(76, 201, 240, 0.7);
    animation: ripple 2.6s ease-out infinite;
    opacity: 0;
}

.sound-marker .ring:nth-child(2) { animation-delay: 0.9s; }
.sound-marker .ring:nth-child(3) { animation-delay: 1.8s; }

.sound-marker.playing .ring { animation-duration: 1.3s; border-color: rgba(239, 216, 111, 0.85); }
.sound-marker.playing .dot { background: linear-gradient(135deg, #ffd166, #ef476f); box-shadow: 0 0 14px rgba(255, 209, 102, 0.9); }

@keyframes ripple {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(3.4); opacity: 0; }
}

/* ---------- Leaflet dark theming ---------- */
.leaflet-container { background: var(--bg); font-family: inherit; }

.leaflet-top.leaflet-left { top: max(64px, calc(env(safe-area-inset-top) + 52px)); }

.leaflet-control-zoom { border: none !important; box-shadow: 0 8px 32px rgba(0,0,0,0.45) !important; border-radius: 12px !important; overflow: hidden; }

.leaflet-control-zoom a {
    background: var(--panel) !important;
    color: var(--text) !important;
    border-color: var(--panel-border) !important;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.leaflet-control-attribution {
    background: rgba(11, 14, 20, 0.6) !important;
    color: var(--text-dim) !important;
    font-size: 10px;
}

.leaflet-control-attribution a { color: var(--accent) !important; }

@media (max-width: 480px) {
    #viz { display: none; }
    #player { grid-template-columns: auto 1fr auto; }
    .brand h1 { font-size: 13px; }
}
