:root {
    --bg:           #0b0b0b;
    --surface:      #141414;
    --surface2:     #1c1c1c;
    --surface3:     #222;
    --border:       #242424;
    --border2:      #2e2e2e;
    --accent:       #7c3aed;
    --accent-h:     #6d28d9;
    --accent-lo:    #7c3aed22;
    --text:         #e8e8e8;
    --muted:        #666;
    --muted2:       #888;
    --danger:       #dc2626;
    --success:      #16a34a;
    --warn:         #d97706;
    --r:            10px;
    --r-sm:         7px;
    --font:         'Inter', -apple-system, sans-serif;
    --header-h:     56px;
    --player-h:     76px;
    --sidebar-w:    200px;
    --safe-top:     env(safe-area-inset-top, 0px);
    --header-total: calc(var(--header-h) + var(--safe-top));
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: var(--font); }
input, select { font-family: var(--font); }

/* ── Splash Screen ───────────────────────────────────── */
.splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.splash.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.splash-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
}
.splash-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.splash-logo svg { color: var(--accent); }
.splash-dots {
    display: flex;
    gap: 7px;
}
.splash-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: splash-pulse 1.2s infinite ease-in-out both;
}
.splash-dots span:nth-child(1) { animation-delay: 0s; }
.splash-dots span:nth-child(2) { animation-delay: 0.2s; }
.splash-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes splash-pulse {
    0%, 80%, 100% { transform: scale(0.55); opacity: 0.25; }
    40%            { transform: scale(1);    opacity: 1; }
}

/* ── Header ─────────────────────────────────────────── */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-total);
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 24px calc(0px) 24px;
    padding-top: var(--safe-top);
    background: rgba(11,11,11,.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.4px;
    padding-bottom: 10px;
}
.logo svg { color: var(--accent); }

/* ── Profile button + dropdown ── */
.profile-wrap { position: relative; padding-bottom: 10px; }

.profile-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--muted2);
    display: flex; align-items: center; justify-content: center;
    transition: all .15s;
    cursor: pointer;
}
.profile-btn:hover { color: var(--text); border-color: #444; background: var(--surface3); }

/* ── Progress ring surrounding profile button ── */
.profile-dl-ring {
    position: absolute;
    top: -3px;
    left: -3px;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 5;
    display: none;
}
.profile-dl-ring-fill {
    transform: rotate(-90deg);
    transform-origin: 20px 20px;
    transition: stroke-dashoffset 0.25s linear;
}
.download-success-pulse {
    animation: success-pulse 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}
@keyframes success-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7); }
    50% { transform: scale(1.2); box-shadow: 0 0 0 10px rgba(139, 92, 246, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}
@media (max-width: 768px) {
    .profile-dl-ring {
        width: 42px;
        height: 42px;
    }
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 210px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: var(--r);
    box-shadow: 0 8px 32px rgba(0,0,0,.65);
    padding: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(.97);
    transform-origin: top right;
    transition: opacity .18s, visibility .18s, transform .18s;
    z-index: 350;
}
.profile-dropdown.open {
    opacity: 1; visibility: visible;
    transform: translateY(0) scale(1);
}

.dd-user-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px 8px;
}
.dd-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent-lo); border: 1px solid var(--accent);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent); flex-shrink: 0;
}
.dd-name  { font-size: 13px; font-weight: 600; }
.dd-email { font-size: 11px; color: var(--muted2); margin-top: 1px; }

.dd-sep { height: 1px; background: var(--border); margin: 4px 0; }

.dd-item {
    display: flex; align-items: center; gap: 9px;
    width: 100%; background: transparent; border: none;
    color: var(--text); padding: 9px 12px;
    border-radius: 6px; font-size: 13px; font-weight: 500;
    text-align: left; cursor: pointer;
    transition: background .1s;
}
.dd-item:hover { background: var(--surface3); }
.dd-item svg   { color: var(--muted2); flex-shrink: 0; }
.dd-item-muted { color: var(--muted2); }
.dd-item-muted:disabled { opacity: .5; cursor: default; }
.dd-item-muted:disabled:hover { background: transparent; }
.dd-soon {
    margin-left: auto;
    font-size: 10px; font-weight: 600;
    background: var(--surface3); color: var(--muted);
    padding: 2px 6px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: .4px;
}

/* ── Download modal ── */
.dl-modal-overlay {
    position: fixed; inset: 0;
    z-index: 600;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--safe-top) + 20px) 16px 20px;
    opacity: 0; visibility: hidden;
    transition: opacity .22s, visibility .22s;
}
.dl-modal-overlay.open { opacity: 1; visibility: visible; }

.dl-modal {
    width: 100%; max-width: 540px;
    max-height: calc(100vh - var(--safe-top) - 48px - env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--r);
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,.8);
    animation: modal-drop .22s cubic-bezier(.4,0,.2,1);
}
@keyframes modal-drop {
    from { transform: translateY(-12px) scale(.96); opacity: 0; }
    to   { transform: translateY(0)     scale(1);   opacity: 1; }
}

.dl-modal-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.dl-modal-title {
    font-size: 14px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.dl-modal-title svg { color: var(--accent); }
.dl-modal-close {
    background: transparent; border: none;
    color: var(--muted2); padding: 5px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .15s;
}
.dl-modal-close:hover { color: var(--text); background: var(--surface3); }
.dl-modal-close:disabled { opacity: .25; pointer-events: none; }
.dl-modal-body {
    flex: 1; overflow-y: auto; padding: 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; scrollbar-color: var(--border2) transparent;
}

/* ── Download page ───────────────────────────────────── */
.page {
    max-width: 680px;
    margin: 0 auto;
    padding: calc(var(--header-h) + 24px) 16px calc(var(--player-h) + 24px);
}

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 24px;
    margin-bottom: 16px;
}

/* ── Field ── */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field > label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .7px; color: var(--muted);
}

/* ── Input ── */
.input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: 14px;
    padding: 9px 13px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-lo); }
.input::placeholder { color: #333; }
.input:disabled { opacity: .35; pointer-events: none; }

/* ── Grid ── */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .row-2 { grid-template-columns: 1fr; } }

/* ── Segmented control ── */
.seg-group {
    display: flex;
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: var(--r-sm);
    padding: 3px; gap: 3px;
}
.seg-group input[type="radio"] { display: none; }
.seg-group label {
    flex: 1; text-align: center;
    padding: 7px 10px;
    border-radius: 5px;
    font-size: 13px; font-weight: 500;
    color: var(--muted2);
    cursor: pointer; transition: all .15s;
    user-select: none; white-space: nowrap;
}
.seg-group label:hover { color: var(--text); }
.seg-group input[type="radio"]:checked + label { background: var(--accent); color: #fff; }

/* ── Qty row ── */
.qty-row { display: flex; align-items: center; gap: 12px; }
.qty-input { width: 80px; flex-shrink: 0; }
.qty-label { color: var(--muted2); white-space: nowrap; }
.qty-sep { flex: 1; height: 1px; background: var(--border); }

/* ── Toggle switch ── */
.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13px; color: var(--muted2); white-space: nowrap; }
.switch input { display: none; }
.switch-track { width: 38px; height: 21px; border-radius: 11px; background: var(--border2); position: relative; flex-shrink: 0; transition: background .2s; }
.switch-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--muted); position: absolute; top: 3px; left: 3px; transition: transform .2s, background .2s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(17px); background: #fff; }
.switch input:checked ~ span { color: var(--text); }

/* ── Advanced details ── */
.advanced { margin-bottom: 20px; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.advanced summary { padding: 11px 16px; font-size: 13px; font-weight: 500; color: var(--muted2); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 7px; user-select: none; transition: color .15s; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: '▸'; font-size: 11px; transition: transform .15s; display: inline-block; }
.advanced[open] summary::before { transform: rotate(90deg); }
.advanced summary:hover { color: var(--text); }
.advanced-body { padding: 16px; border-top: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; gap: 14px; }
.advanced-body .field { margin-bottom: 0; }

/* ── Checkbox label ── */
.check-label { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--muted2); user-select: none; }
.check-label input[type="checkbox"] { display: none; }
.check-box { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border2); background: var(--bg); flex-shrink: 0; position: relative; transition: all .15s; }
.check-label input:checked + .check-box { background: var(--accent); border-color: var(--accent); }
.check-label input:checked + .check-box::after { content: ''; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px; border: 2px solid #fff; border-left: none; border-top: none; transform: rotate(45deg); }

/* ── Buttons ── */
.btn-primary { width: 100%; padding: 11px; background: var(--accent); color: #fff; border: none; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, transform .1s; margin-top: 4px; }
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:active { transform: scale(.99); }
.btn-primary:disabled { opacity: .45; pointer-events: none; }
.btn-danger { padding: 10px 24px; background: transparent; color: var(--danger); border: 1px solid var(--danger); border-radius: var(--r-sm); font-size: 14px; font-weight: 500; transition: all .15s; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-secondary { padding: 9px 14px; background: var(--surface2); color: var(--muted2); border: 1px solid var(--border2); border-radius: var(--r-sm); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; white-space: nowrap; transition: all .15s; }
.btn-secondary:hover { color: var(--text); border-color: #444; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }

/* ── Form error ── */
.form-error { color: #f87171; font-size: 13px; padding: 10px 14px; background: rgba(220,38,38,.1); border: 1px solid rgba(220,38,38,.25); border-radius: var(--r-sm); margin-bottom: 14px; word-break: break-word; }

/* ── Download progress ── */
.dl-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.dl-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80%; }
.dl-pct { font-size: 13px; font-weight: 600; color: var(--accent); flex-shrink: 0; }
.prog-track { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; margin-bottom: 16px; }
.prog-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #a78bfa); border-radius: 2px; transition: width .4s ease; }
.logs { height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
.logs::-webkit-scrollbar { width: 4px; }
.logs::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.log-entry { display: flex; align-items: flex-start; gap: 9px; padding: 7px 10px; border-radius: 6px; font-size: 13px; }
.log-icon { flex-shrink: 0; width: 16px; text-align: center; margin-top: 1px; font-size: 11px; }
.log-msg { flex: 1; word-break: break-word; }
.log-starting   { background: rgba(124,58,237,.08); color: var(--text); }
.log-searching  { color: var(--muted2); }
.log-loading    { color: #60a5fa; }
.log-moving, .log-restoring_meta { color: var(--muted2); }
.log-finished   { color: #4ade80; }
.log-skipped    { color: var(--muted); }
.log-failed     { color: var(--warn); background: rgba(217,119,6,.07); }
.log-error      { color: #f87171; background: rgba(220,38,38,.08); }
.log-stop       { color: var(--warn); }
.log-info       { color: var(--muted2); font-style: italic; }

/* ══════════════════════════════════════════════════════
   LIBRARY
══════════════════════════════════════════════════════ */
.lib-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-top: var(--header-total);
    padding-bottom: var(--player-h);
    overflow: hidden;
}

/* Top bar */
.lib-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.lib-search-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: var(--r-sm);
    padding: 8px 12px;
}
.lib-search-wrap svg { color: var(--muted); flex-shrink: 0; }
.lib-search-wrap input { background: transparent; border: none; outline: none; color: var(--text); font-size: 13px; width: 100%; }
.lib-search-wrap input::placeholder { color: var(--muted); }
.lib-dir-wrap { display: flex; align-items: center; gap: 8px; }

/* Body */
.lib-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.lib-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}
.lib-nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }
.lib-nav-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); padding: 6px 10px 4px; }
.lib-nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    border: none; background: transparent;
    color: var(--muted2);
    font-size: 13px; font-weight: 500;
    text-align: left; cursor: pointer;
    transition: all .12s;
    position: relative;
}
.lib-nav-item:hover { background: var(--surface2); color: var(--text); }
.lib-nav-item.active { background: var(--accent-lo); color: var(--accent); }
.lib-nav-item.active svg { stroke: var(--accent); }
.lib-badge {
    margin-left: auto;
    background: var(--surface3);
    color: var(--muted2);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
}
.lib-badge:empty { display: none; }

/* Sort panel */
.lib-sort-panel { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }
.sort-opt { padding: 7px 10px; border-radius: var(--r-sm); border: none; background: transparent; color: var(--muted2); font-size: 12px; font-weight: 500; text-align: left; cursor: pointer; transition: all .12s; display: flex; align-items: center; justify-content: space-between; }
.sort-opt:hover { background: var(--surface2); color: var(--text); }
.sort-opt.active { color: var(--accent); }
.sort-opt .sort-arrow { font-size: 10px; opacity: .7; }

/* Main content */
.lib-main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}
.lib-main::-webkit-scrollbar { width: 6px; }
.lib-main::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* Breadcrumb */
.lib-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    font-size: 13px;
    color: var(--muted2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.lib-breadcrumb .bc-item { cursor: pointer; color: var(--accent); }
.lib-breadcrumb .bc-item:hover { text-decoration: underline; }
.lib-breadcrumb .bc-sep { color: var(--muted); }
.lib-breadcrumb .bc-current { color: var(--text); font-weight: 500; cursor: default; }

/* Content area */
.lib-content { flex: 1; }

/* Empty state */
.lib-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; padding: 80px 20px;
    color: var(--muted); font-size: 13px; text-align: center;
}

/* ── Track Table ── */
.track-table { width: 100%; }

.track-table-head {
    display: grid;
    grid-template-columns: 36px 44px 1fr 180px 180px 60px 56px 36px;
    gap: 0;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .6px;
    color: var(--muted);
    position: sticky; top: 0;
    background: var(--bg);
    z-index: 10;
}
.track-table-head .th { padding: 4px 8px; cursor: pointer; border-radius: 4px; transition: color .12s; display: flex; align-items: center; gap: 4px; }
.track-table-head .th:hover { color: var(--text); }
.track-table-head .th.active { color: var(--accent); }
.track-table-head .th-num, .track-table-head .th-art { cursor: default; }
.track-table-head .th-num { text-align: right; }

.track-row {
    display: grid;
    grid-template-columns: 36px 44px 1fr 180px 180px 60px 56px 36px;
    gap: 0;
    padding: 0 16px;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,.03);
    cursor: pointer;
    transition: background .1s;
    min-height: 52px;
}
.track-row:hover { background: var(--surface2); }
.track-row.playing { background: var(--accent-lo); }
.track-row.playing .tr-title { color: var(--accent); }

.tr-num { font-size: 12px; color: var(--muted); text-align: right; padding: 0 8px; }
.track-row:hover .tr-num,
.track-row.playing .tr-num { display: none; }
.tr-play-icon { display: none; font-size: 11px; color: var(--accent); text-align: right; padding: 0 8px; }
.track-row:hover .tr-play-icon,
.track-row.playing .tr-play-icon { display: block; }

/* Thumbnail */
.tr-art { padding: 0 6px; }
.art-thumb {
    width: 36px; height: 36px;
    border-radius: 4px;
    object-fit: cover;
    display: block;
    background: var(--surface3);
}
.art-ph {
    width: 36px; height: 36px;
    border-radius: 4px;
    background: var(--surface3);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    color: var(--muted);
    flex-shrink: 0;
}

.tr-title-col { padding: 0 8px; min-width: 0; }
.tr-title-wrapper { display: flex; align-items: center; min-width: 0; gap: 6px; }
.tr-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.tr-title-sub { font-size: 11px; color: var(--muted2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tr-artist, .tr-album { font-size: 12px; color: var(--muted2); padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-artist:hover, .tr-album:hover { color: var(--text); text-decoration: underline; }

.tr-year { font-size: 12px; color: var(--muted); padding: 0 8px; }
.tr-dur { font-size: 12px; color: var(--muted); padding: 0 8px; font-variant-numeric: tabular-nums; }

.tr-fav {
    padding: 0 4px; display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: var(--muted); opacity: 0;
    transition: opacity .12s, color .12s;
}
.track-row:hover .tr-fav { opacity: 1; }
.tr-fav.faved { color: #f43f5e; opacity: 1; }
.tr-fav:hover { color: #f43f5e !important; }

/* ── Album Grid ── */
.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 20px;
}

.album-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.album-card:hover { transform: translateY(-2px); border-color: var(--border2); box-shadow: 0 8px 24px rgba(0,0,0,.4); }

.album-art-wrap {
    width: 100%; aspect-ratio: 1;
    background: var(--surface2);
    position: relative; overflow: hidden;
}
.album-art-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-art-ph {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
}
.album-art-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .15s;
}
.album-art-overlay svg { color: #fff; }
.album-card:hover .album-art-overlay { opacity: 1; }

.album-info { padding: 10px 12px; }
.album-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.album-artist { font-size: 12px; color: var(--muted2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── Artist Grid ── */
.artist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
    padding: 20px;
}

.artist-card {
    display: flex; flex-direction: column;
    align-items: center; gap: 10px;
    padding: 20px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    cursor: pointer;
    transition: transform .15s, border-color .15s;
    text-align: center;
}
.artist-card:hover { transform: translateY(-2px); border-color: var(--border2); }

.artist-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 700;
    color: rgba(255,255,255,.9);
    flex-shrink: 0;
}
.artist-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.artist-meta { font-size: 11px; color: var(--muted2); }

/* ── Album detail header ── */
.album-detail-header {
    display: flex;
    align-items: flex-end;
    gap: 24px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface2) 0%, transparent 100%);
    flex-shrink: 0;
}
.album-detail-art {
    width: 140px; height: 140px;
    border-radius: var(--r);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--surface3);
}
.album-detail-art-ph {
    width: 140px; height: 140px;
    border-radius: var(--r);
    background: var(--surface3);
    display: flex; align-items: center; justify-content: center;
    font-size: 48px;
    flex-shrink: 0;
}
.album-detail-info { min-width: 0; }
.album-detail-type { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--muted2); margin-bottom: 6px; }
.album-detail-name { font-size: 26px; font-weight: 700; letter-spacing: -.5px; line-height: 1.2; margin-bottom: 6px; }
.album-detail-sub { font-size: 14px; color: var(--muted2); }
.album-detail-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Track table for album detail (without artist col) */
.track-table.no-artist .track-table-head,
.track-table.no-artist .track-row {
    grid-template-columns: 36px 44px 1fr 60px 56px 36px;
}

/* ── Player bar ─────────────────────────────────────── */
.player {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--player-h);
    background: rgba(11,11,11,.97);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 400;
}

.player-info { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }

.player-art-wrap {
    width: 44px; height: 44px;
    border-radius: 6px;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--surface2);
    display: flex; align-items: center; justify-content: center;
}
.player-art-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.player-art-ph { font-size: 18px; color: var(--muted); }

.player-meta { min-width: 0; }
.player-track { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.player-sub { font-size: 11px; color: var(--muted2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

.player-center { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 2; }
.player-controls { display: flex; align-items: center; gap: 8px; }

.ctrl-btn { background: transparent; border: none; color: var(--muted2); padding: 4px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: color .15s, background .15s; }
.ctrl-btn:hover { color: var(--text); background: var(--surface2); }
.play-btn { width: 36px; height: 36px; background: var(--accent) !important; color: #fff !important; border-radius: 50%; }
.play-btn:hover { background: var(--accent-h) !important; }

.seek-wrap { display: flex; align-items: center; gap: 8px; width: 100%; }
.time { font-size: 11px; color: var(--muted); width: 34px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
#time-dur { text-align: right; }

.player-right { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }

/* ── Range inputs ── */
.seek-bar, .vol-bar {
    -webkit-appearance: none; appearance: none;
    height: 3px; border-radius: 2px;
    background: var(--border2);
    outline: none; cursor: pointer;
    touch-action: none;
    transition: height .12s;
}
.seek-bar { flex: 1; }
.vol-bar { width: 80px; }
.seek-bar:hover, .vol-bar:hover { height: 5px; }
.seek-bar::-webkit-slider-thumb, .vol-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); cursor: pointer; }
.seek-bar::-moz-range-thumb, .vol-bar::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: none; cursor: pointer; }

/* ── Playlist sidebar ──────────────────────────────── */
.lib-pl-group { margin-top: 4px; }
.lib-pl-header { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; margin-bottom: 2px; }
.lib-pl-add {
    background: transparent; border: none;
    color: var(--muted); padding: 2px;
    border-radius: 4px; display: flex; align-items: center; justify-content: center;
    transition: color .15s, background .15s;
}
.lib-pl-add:hover { color: var(--text); background: var(--surface3); }

.pl-item {
    display: flex; align-items: center;
    gap: 6px;
    width: 100%;
    background: transparent; border: none;
    color: var(--muted2);
    padding: 5px 8px;
    border-radius: var(--r-sm);
    font-size: 13px; font-weight: 400;
    text-align: left; cursor: pointer;
    transition: background .12s, color .12s;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-item:hover { background: var(--surface3); color: var(--text); }
.pl-item.active { background: var(--accent-lo); color: var(--text); font-weight: 500; }
.pl-item svg { flex-shrink: 0; opacity: .5; }

/* ── Context menu ──────────────────────────────────── */
.ctx-menu {
    position: fixed;
    z-index: 900;
    min-width: 200px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: var(--r);
    box-shadow: 0 8px 32px rgba(0,0,0,.6);
    padding: 4px;
    user-select: none;
}
.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }
.ctx-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); padding: 4px 10px 2px; }
.ctx-item {
    display: flex; align-items: center; gap: 8px;
    width: 100%; background: transparent; border: none;
    color: var(--text); padding: 7px 10px;
    border-radius: 6px; font-size: 13px; text-align: left; cursor: pointer;
    transition: background .1s;
}
.ctx-item:hover { background: var(--surface3); }
.ctx-item svg { color: var(--muted2); flex-shrink: 0; }
.ctx-item-new { color: var(--muted2); font-size: 12px; }
.ctx-item-new:hover { color: var(--text); }
.ctx-item-remove { color: var(--danger); }
.ctx-item-remove:hover { background: rgba(220,38,38,.1); }

/* ── New playlist dialog ───────────────────────────── */
.pl-dialog-overlay {
    position: fixed; inset: 0;
    z-index: 800;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
}
.pl-dialog {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: var(--r);
    padding: 24px;
    width: 340px;
    box-shadow: 0 16px 48px rgba(0,0,0,.7);
}
.pl-dialog-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.pl-dialog-input { width: 100%; margin-bottom: 16px; }
.pl-dialog-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Player idle state (nothing loaded yet) ── */
.player-idle .ctrl-btn,
.player-idle .play-btn { opacity: .3; pointer-events: none; }
.player-idle .seek-bar,
.player-idle .vol-bar  { opacity: .25; pointer-events: none; }
.player-idle .player-track { opacity: .35; }
.player-idle .player-sub   { opacity: .25; }

/* ── Library menu button (hidden on desktop) ── */
.lib-menu-btn {
    display: none;
    background: transparent; border: none;
    color: var(--muted2); padding: 6px;
    border-radius: var(--r-sm);
    align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: color .15s;
}
.lib-menu-btn:hover { color: var(--text); }

/* ── Sidebar backdrop (mobile) ── */
.lib-sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    z-index: 499;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
}
.lib-sidebar-backdrop.show { display: block; }

/* ══════════════════════════════════════════════════════
   MOBILE  ≤ 768 px
══════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Touch targets & tap delay */
    button, [role="button"], input[type="range"],
    .track-row, .album-card, .artist-card { touch-action: manipulation; }

    /* Prevent iOS zoom on focus (inputs must have font-size >= 16px) */
    input, select, textarea, .input, .lib-search-wrap input {
        font-size: 16px !important;
    }

    /* Player height variable (2-row layout + safe area) */
    :root {
        --player-h: calc(108px + env(safe-area-inset-bottom, 0px));
    }

    /* ── Header ── */
    .header { padding-left: 14px; padding-right: 14px; }
    .profile-btn { width: 36px; height: 36px; }
    /* dropdown full-width on small screens */
    .profile-dropdown { right: -4px; min-width: 190px; }

    /* ── Download page ── */
    .page {
        padding: calc(var(--header-h) + 14px) 12px
                 calc(var(--player-h) + 20px);
    }
    .card { padding: 16px; }
    .logs { height: 200px; }
    .btn-row { flex-direction: column; }
    .btn-danger { text-align: center; }

    /* ── Library topbar ── */
    .lib-topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
    .lib-search-wrap { order: 1; flex: 1 1 auto; min-width: 0; }
    .lib-menu-btn { display: flex; order: 0; }
    .lib-dir-wrap { order: 2; width: 100%; }
    .lib-dir-wrap .input { flex: 1; width: auto; min-width: 0; }
    .refresh-label { display: none; }

    /* ── Sidebar → slide-in drawer ── */
    .lib-sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0;
        bottom: 0;
        z-index: 500;
        transform: translateX(-105%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        width: 270px;
        box-shadow: 4px 0 32px rgba(0,0,0,.6);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .lib-sidebar.open { transform: translateX(0); }

    /* ── Track table: compact columns ── */
    .track-table-head,
    .track-row {
        grid-template-columns: 44px 1fr 48px 44px;
    }
    /* hide columns that don't fit */
    .th-art, .tr-art,
    .th-artist, .th-album,
    .th-year, .tr-year { display: none; }
    /* artist & album cols in data rows are conditionally rendered by JS */
    .track-row .tr-artist,
    .track-row .tr-album { display: none; }

    /* always show artist sub-line under title (overrides inline style) */
    .tr-title-sub { display: block !important; color: var(--muted2); }

    /* fav always visible (no hover on touch) */
    .tr-fav { opacity: 1 !important; }

    /* bigger touch target for rows */
    .track-row { min-height: 60px; padding: 0 10px; }
    .tr-title-col { padding: 0 6px; }

    /* no-artist table same compact grid */
    .track-table.no-artist .track-table-head,
    .track-table.no-artist .track-row {
        grid-template-columns: 44px 1fr 48px 44px;
    }

    /* ── Album grid: 2 columns ── */
    .album-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px; padding: 12px;
    }

    /* ── Artist grid ── */
    .artist-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px; padding: 12px;
    }
    .artist-avatar { width: 60px; height: 60px; font-size: 22px; }
    .artist-card { padding: 14px 8px; }

    /* ── Album detail header: stack ── */
    .album-detail-header {
        flex-direction: column; align-items: flex-start;
        gap: 14px; padding: 14px;
    }
    .album-detail-art, .album-detail-art-ph { width: 90px; height: 90px; }
    .album-detail-name { font-size: 20px; }

    /* ── Player bar: 2-row mobile layout ── */
    .player {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
        gap: 6px;
        align-items: center;
    }
    .player-info {
        flex: 1;
        min-width: 0;
        order: 1;
    }
    .player-track { max-width: none; font-size: 13px; }
    .player-sub   { max-width: none; }
    .player-center {
        order: 2;
        flex: none;
    }
    .seek-wrap {
        order: 3;
        width: 100%;
        padding: 0 2px;
    }
    .player-right { display: none; } /* hide volume on mobile */

    .player-controls { gap: 2px; }
    .ctrl-btn { min-width: 40px; min-height: 40px; }
    .play-btn  { width: 40px; height: 40px; }

    /* ── Context menu → bottom sheet ── */
    .ctx-menu {
        top: auto !important;
        bottom: env(safe-area-inset-bottom, 0px) !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        min-width: unset !important;
        border-radius: 16px 16px 0 0 !important;
        padding: 6px 4px calc(12px + env(safe-area-inset-bottom, 0px));
        animation: ctx-slide-up .22s cubic-bezier(.4,0,.2,1);
    }
    @keyframes ctx-slide-up {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0);   opacity: 1; }
    }
    .ctx-item { padding: 12px 14px; font-size: 15px; }
    .ctx-label { padding: 6px 14px 2px; }

    /* ── Download modal on mobile (Full-screen bottom-sheet presentation) ── */
    .dl-modal-overlay {
        padding: 0;
        align-items: flex-end;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    .dl-modal-overlay .dl-modal {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: var(--bg);
        transform: translateY(100%);
        transition: transform .28s cubic-bezier(0.1, 0.76, 0.55, 0.94);
        animation: none; /* override desktop keyframe animation */
    }
    .dl-modal-overlay.open .dl-modal {
        transform: translateY(0);
    }
    .dl-modal-topbar {
        padding: calc(var(--safe-top, 0px) + 16px) 20px 16px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }
    .dl-modal-body {
        padding: 20px;
        background: var(--bg);
        padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    }
    
    /* iOS Card-style inputs and layout optimization */
    .dl-modal .field {
        margin-bottom: 20px;
    }
    .dl-modal .input {
        font-size: 16px !important;
        padding: 12px 14px;
        border-radius: 10px;
        background: var(--surface);
        border: 1px solid var(--border);
    }
    .dl-modal .seg-group {
        border-radius: 10px;
        background: var(--surface);
        border: 1px solid var(--border);
        padding: 3.5px;
    }
    .dl-modal .seg-group label {
        padding: 10px 12px;
        font-size: 13px;
        font-weight: 600;
        border-radius: 7px;
    }
    .dl-modal .qty-row {
        background: var(--surface);
        border: 1px solid var(--border);
        padding: 12px 14px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
    }
    .dl-modal .qty-sep {
        display: none;
    }
    .dl-modal .qty-input {
        background: var(--surface2);
        border: 1px solid var(--border2);
        border-radius: 8px;
        padding: 8px 12px;
        width: 76px;
        text-align: center;
    }
    .dl-modal .advanced {
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--surface);
    }
    .dl-modal .advanced summary {
        padding: 14px;
        font-size: 14px;
        font-weight: 600;
    }
    .dl-modal .advanced-body {
        padding: 16px;
        background: var(--bg);
        border-top: 1px solid var(--border);
        gap: 16px;
    }
    .dl-modal .btn-primary {
        padding: 14px;
        border-radius: 10px;
        font-size: 15px;
        font-weight: 600;
        margin-top: 16px;
    }
    .dl-modal .logs {
        height: 250px;
        background: var(--surface2);
        border-radius: 10px;
        padding: 12px;
        border: 1px solid var(--border);
        margin-top: 14px;
    }
    
    /* Ensure 2-column layout stacks on mobile */
    .row-2 {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    /* ── Dialog: full width ── */
    .pl-dialog {
        width: calc(100vw - 24px);
        max-width: 380px;
    }

    /* ── Nav items: bigger touch targets ── */
    .lib-nav-item { min-height: 46px; }
    .sort-opt { min-height: 40px; }
    .pl-item  { min-height: 40px; }

    /* ── Breadcrumb ── */
    .lib-breadcrumb { padding: 10px 14px; }

    /* ── Empty state ── */
    .lib-empty { padding: 48px 20px; }

    /* ── Qty row: wrap on very small ── */
    .qty-row { flex-wrap: wrap; }
}

/* ── Extra small (≤ 380 px) ── */
@media (max-width: 380px) {
    .logo span { display: none; }          /* keep only icon in header */
    .album-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px; }
}

/* ── Smooth scrolling on iOS ── */
.lib-main, .lib-sidebar, .logs {
    -webkit-overflow-scrolling: touch;
}


/* ── Auth overlay ───────────────────────────────────── */
.auth-overlay {
    position: fixed; inset: 0;
    z-index: 10000;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    opacity: 0; visibility: hidden;
    transition: opacity .25s, visibility .25s;
}
.auth-overlay.open { opacity: 1; visibility: visible; }

.auth-card {
    width: 100%; max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: calc(var(--r) * 1.5);
    padding: 36px 32px 28px;
    display: flex; flex-direction: column; gap: 20px;
}

.auth-logo {
    display: flex; align-items: center; gap: 10px;
    font-size: 22px; font-weight: 700; letter-spacing: -.5px;
    color: var(--text); justify-content: center;
    margin-bottom: 4px;
}
.auth-logo svg { color: var(--accent); }

.auth-title {
    font-size: 18px; font-weight: 600;
    text-align: center; color: var(--text);
    margin: -12px 0 -4px;
}

.auth-error {
    background: rgba(220,38,38,.12);
    border: 1px solid rgba(220,38,38,.3);
    color: #fca5a5;
    border-radius: var(--r-sm);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.45;
}

#auth-form { display: flex; flex-direction: column; gap: 14px; }

.auth-submit {
    margin-top: 4px;
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
}

.auth-switch {
    text-align: center;
    font-size: 13px;
    color: var(--muted2);
}
.auth-switch-btn {
    background: none; border: none;
    color: var(--accent); font-size: 13px; font-weight: 600;
    cursor: pointer; padding: 0; margin-left: 4px;
    text-decoration: underline;
}
.auth-switch-btn:hover { color: var(--accent-h); }

/* ── Logout / danger dd-item ────────────────────────── */
.dd-item-danger { color: #f87171; }
.dd-item-danger svg { color: #f87171; }
.dd-item-danger:hover { background: rgba(220,38,38,.12); }

/* ── Offline cached indicator on tracks ─────────────── */
.tr-offline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: var(--success);
    background: rgba(22, 163, 74, 0.12);
    border: 1px solid rgba(22, 163, 74, 0.25);
    border-radius: 4px;
    padding: 2px 5px;
    line-height: 1;
    font-weight: 600;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .auth-card { padding: 28px 20px 24px; }
}

/* ── Toast notifications ────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: calc(var(--player-h) + 20px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text);
    padding: 12px 20px;
    border-radius: var(--r);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,.5);
    transform: translateY(20px);
    opacity: 0;
    transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s;
    pointer-events: auto;
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}
.toast-success {
    border-left: 4px solid var(--success);
}
.toast-info {
    border-left: 4px solid var(--accent);
}
.toast-error {
    border-left: 4px solid var(--danger);
}

@media (max-width: 768px) {
    #toast-container {
        left: 20px;
        right: 20px;
        bottom: calc(var(--player-h) + 16px);
    }
    .toast {
        text-align: center;
    }
}

/* ── Fullscreen mobile player ───────────────────────── */
.fs-player {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    background: var(--bg);
    z-index: 99999;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.94, 0.6, 1);
    display: flex;
    flex-direction: column;
    padding: var(--safe-top) 24px calc(16px + env(safe-area-inset-bottom, 16px));
    user-select: none;
    box-sizing: border-box;
}

.fs-player.open {
    transform: translateY(0);
}

.fs-header {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    width: 100%;
}

.fs-drag-handle {
    width: 36px;
    height: 5px;
    background: var(--border2);
    border-radius: 3px;
    transition: background 0.2s;
}
.fs-header:hover .fs-drag-handle {
    background: var(--muted2);
}

.fs-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    min-height: 0;
}

/* Large Album Art */
.fs-art-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    max-width: 300px;
    margin: 0 auto;
}

.fs-art-wrap {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
    aspect-ratio: 1;
}

.fs-art-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fs-art-ph {
    font-size: 80px;
    color: var(--muted);
}

/* Meta & Action buttons row */
.fs-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 16px;
    gap: 16px;
}

.fs-meta {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.fs-track {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fs-sub {
    font-size: 14px;
    color: var(--muted2);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fs-actions {
    display: flex;
    gap: 12px;
}

.fs-action-btn {
    background: none;
    border: none;
    color: var(--muted2);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

.fs-action-btn:hover {
    color: var(--text);
    background: var(--surface2);
}

.fs-action-btn.faved {
    color: var(--danger) !important;
}

/* Seek Bar */
.fs-seek-container {
    width: 100%;
    margin-top: 16px;
}

.fs-seek-bar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: var(--border2);
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

.fs-seek-bar::-webkit-slider-runnable-track {
    width: 100%;
    height: 5px;
    cursor: pointer;
    border-radius: 3px;
}

.fs-seek-bar::-webkit-slider-thumb {
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--text);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.fs-time-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--muted2);
    margin-top: 6px;
}

/* Controls */
.fs-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    margin-top: 16px;
}

.fs-ctrl-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    transition: transform 0.1s, opacity 0.15s;
}

.fs-ctrl-btn:active {
    transform: scale(0.95);
}

.fs-play-btn {
    width: 64px;
    height: 64px;
    background: var(--text);
    color: var(--bg);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.fs-play-btn svg {
    color: var(--bg);
}

/* Footer / volume & tools */
.fs-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 16px;
    gap: 16px;
}

.fs-tool-btn {
    background: none;
    border: none;
    color: var(--muted2);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.fs-tool-btn:hover,
.fs-tool-btn.active {
    color: var(--accent);
}

.fs-vol-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 180px;
}

.fs-vol-bar {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border2);
    outline: none;
}

.fs-vol-bar::-webkit-slider-thumb {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    background: var(--muted2);
    cursor: pointer;
    -webkit-appearance: none;
}

/* Playlist selector modal styling */
.fs-pl-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    margin: 12px 0;
    padding-right: 4px;
}
.fs-pl-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 14px;
    border-radius: var(--r);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
}
.fs-pl-item:hover {
    background: var(--surface3);
    border-color: var(--border2);
}
.fs-pl-item.in-pl {
    background: rgba(22, 163, 74, 0.12);
    border-color: rgba(22, 163, 74, 0.25);
    color: var(--success);
}

@media (max-width: 768px) {
    #player {
        cursor: pointer;
    }
}

/* Hide fs-player on Desktop */
@media (min-width: 769px) {
    .fs-player {
        display: none !important;
    }
}
