:root {
    color-scheme: dark;
    --bg: #052832;
    --bg-deep: #031d25;
    --panel: #0a3440;
    --text: #f5f7f7;
    --muted: #78919a;
    --border: rgba(255,255,255,.08);
    --danger: #ff9a9a;
    --ok: #8be0b4;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin:0; min-width:320px; background:var(--bg); color:var(--text); }
button,input { font:inherit; }
button {
    min-height:44px; border:1px solid var(--border); border-radius:14px; padding:0 18px;
    background:rgba(255,255,255,.08); color:var(--text); cursor:pointer;
}
button.primary { background:#f7f7f2; color:#062832; border-color:transparent; font-weight:800; }
button.danger { border-color:rgba(255,154,154,.45); color:#ffd0d0; }
input {
    width:100%; min-height:46px; margin-top:8px; border:1px solid var(--border); border-radius:12px;
    background:rgba(0,0,0,.18); color:var(--text); padding:10px 12px;
}
label { display:block; color:#c7d2d5; font-size:.92rem; }
code {
    display:block; max-width:100%; overflow-wrap:anywhere; padding:10px 12px; border-radius:10px;
    background:rgba(0,0,0,.22); color:#d4e5e9;
}
.app-shell { display:grid; grid-template-columns:118px minmax(0,1fr); min-height:100vh; }
.rail {
    position:sticky; top:0; height:100vh; background:var(--bg-deep); display:flex; flex-direction:column;
    align-items:center; padding:22px 0; border-right:1px solid var(--border); z-index:10;
}
.brand-mark {
    width:46px; height:46px; display:grid; place-items:center; border-radius:50%; background:white;
    color:#041e26; font-family:Georgia,serif; font-size:26px; font-style:italic; font-weight:700;
}
.nav-stack { flex:1; width:100%; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:28px; }
.nav-link {
    writing-mode:vertical-rl; transform:rotate(180deg); text-decoration:none; color:#65808a;
    font-weight:800; letter-spacing:.02em;
}
.nav-link.active,.nav-link:hover { color:white; }
.gear { text-decoration:none; font-size:26px; color:#76939e; }
.content { min-width:0; padding:38px clamp(24px,5vw,76px) 60px; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap:24px; margin-bottom:34px; }
h1,h2,h3,p { margin-top:0; }
h1 { margin-bottom:0; font-family:Georgia,serif; font-size:clamp(2rem,4vw,3.4rem); font-style:italic; }
h2 { margin-bottom:0; font-size:clamp(1.75rem,3vw,2.55rem); line-height:1.05; }
h3 { margin-bottom:14px; }
.eyebrow { margin-bottom:6px; font-size:.75rem; font-weight:900; letter-spacing:.16em; color:#7fa1aa; }
.status-cluster { display:flex; align-items:center; gap:9px; color:#c5d3d6; font-size:.92rem; }
.status-dot { width:10px; height:10px; border-radius:50%; background:#e88a8a; }
.status-dot.ok { background:var(--ok); }
.flash { margin:0 0 18px; border-radius:12px; padding:12px 14px; background:rgba(255,255,255,.08); }
.flash.success { border-left:4px solid var(--ok); }
.flash.error { border-left:4px solid var(--danger); }
.section { padding:30px 0 46px; scroll-margin-top:20px; }
.section-heading { display:flex; justify-content:space-between; gap:20px; align-items:end; margin-bottom:18px; }
.panel { border:1px solid var(--border); border-radius:20px; background:rgba(3,29,37,.34); padding:22px; }
.auth-layout { display:grid; gap:24px; }
.hero-card {
    padding:clamp(26px,5vw,56px); background:linear-gradient(135deg,rgba(255,255,255,.09),rgba(255,255,255,.02));
    border-radius:24px; border:1px solid var(--border);
}
.auth-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.auth-grid form { display:grid; gap:16px; }
.quick-grid { display:grid; grid-template-columns:minmax(0,1.55fr) minmax(280px,.75fr); gap:22px; }
.quick-list { display:grid; gap:9px; }
.quick-item { display:grid; grid-template-columns:82px minmax(0,1fr); align-items:center; gap:18px; padding:10px; border-radius:14px; }
.quick-item:hover { background:rgba(255,255,255,.04); }
.quick-item strong,.quick-item span { display:block; }
.quick-item strong { font-size:1.12rem; margin-bottom:4px; }
.quick-item span,.shelf-card small,.empty-state p { color:var(--muted); }
.album-placeholder {
    width:82px; aspect-ratio:1; display:grid; place-items:center; border-radius:12px;
    background:linear-gradient(145deg,#48646b,#173b45); color:rgba(255,255,255,.86); font-weight:900; letter-spacing:.08em;
}
.health-panel h3 { overflow-wrap:anywhere; font-size:1rem; color:#d7e4e7; }
.health-row { display:flex; justify-content:space-between; gap:18px; border-top:1px solid var(--border); padding:13px 0; }
.health-row b { color:#b9d8cd; font-size:.82rem; }
.shelf-title { margin-top:34px; }
.shelf {
    display:grid; grid-auto-flow:column; grid-auto-columns:minmax(180px,220px); gap:18px; overflow-x:auto;
    padding:2px 2px 14px; scroll-snap-type:x proximity;
}
.shelf-card { scroll-snap-align:start; }
.shelf-card strong,.shelf-card small { display:block; }
.shelf-card strong { margin-top:10px; font-size:1.03rem; }
a.shelf-card { display:block; text-decoration:none; color:inherit; }
.cover {
    aspect-ratio:1; display:grid; place-items:end start; border-radius:16px; padding:18px;
    font-size:1.7rem; font-weight:900; border:1px solid rgba(255,255,255,.08);
    background:linear-gradient(145deg,#6a7b80,#102d36); color:rgba(255,255,255,.7);
}
.cover-a { background:linear-gradient(145deg,#9d9380,#313d41); }
.cover-b { background:linear-gradient(145deg,#6a7b80,#102d36); }
.cover-c { background:linear-gradient(145deg,#83715b,#183e49); }
.cover-d { background:linear-gradient(145deg,#40636b,#101f28); }

.cover-art {
    aspect-ratio:1; border-radius:16px; overflow:hidden; position:relative;
    border:1px solid rgba(255,255,255,.08);
    background:linear-gradient(145deg,#6a7b80,#102d36);
}
.cover-art img { width:100%; height:100%; object-fit:cover; display:block; }
.cover-art .art-fallback {
    position:absolute; inset:0; display:grid; place-items:center;
    font-size:1.7rem; font-weight:900; color:rgba(255,255,255,.7); opacity:0;
}
.cover-art.art-failed img { display:none; }
.cover-art.art-failed .art-fallback { opacity:1; }
.empty-state { min-height:170px; display:grid; content:center; justify-items:start; }
.settings-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
dl { display:grid; grid-template-columns:110px 1fr; gap:9px 18px; }
dt { color:var(--muted); }
dd { margin:0; overflow-wrap:anywhere; }
.inline-form { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-top:18px; }
.toggle-line { display:flex; align-items:center; gap:10px; flex:1; }
.toggle-line input { width:22px; min-height:22px; margin:0; }
.device-list { list-style:none; margin:0; padding:0; }
.device-list li { display:flex; justify-content:space-between; gap:12px; padding:11px 0; border-top:1px solid var(--border); }
.device-list span { color:var(--muted); }
footer { padding-top:34px; color:#67848d; font-size:.82rem; }

/* ─── Server Check Cards ─────────────────────────────────── */
.check-cards {
    display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:18px;
}
.check-card {
    border:1px solid var(--border); border-radius:16px; padding:20px;
    display:flex; flex-direction:column; align-items:center; gap:10px;
    position:relative; overflow:hidden; min-height:140px;
}
.check-card-icon { width:48px; height:48px; color:rgba(255,255,255,.6); }
.check-card-icon .check-icon { width:100%; height:100%; }
.check-card-status { position:absolute; top:12px; right:12px; }
.check-badge { width:24px; height:24px; }
.check-badge.check-pass { color:var(--ok); }
.check-badge.check-fail-icon { color:var(--danger); }
.check-card-label { font-size:1rem; font-weight:700; color:var(--text); }
.check-card-meta { font-size:.85rem; color:var(--muted); }

.check-card-auth {
    background:linear-gradient(135deg, rgba(70,110,120,.3), rgba(40,80,90,.15));
}
.check-card-history {
    background:rgba(3,29,37,.34);
}
.check-card-health {
    background:rgba(3,29,37,.34);
}

.check-card.check-ok { border-color:rgba(139,224,180,.25); }
.check-card.check-fail { border-color:rgba(255,154,154,.25); }

@media (max-width:700px) {
    .check-cards { grid-template-columns:1fr; }
}

/* ─── Explicit Badge ─────────────────────────────────────── */
.explicit-badge {
    display:inline-block; margin-left:6px; padding:1px 5px; border-radius:4px;
    font-size:.7rem; font-weight:800; background:rgba(255,154,154,.2); color:var(--danger);
    vertical-align:middle; letter-spacing:.04em;
}

/* ─── Favorite Heart Button ──────────────────────────────── */
.fav-btn {
    background:none; border:none; cursor:pointer; font-size:18px; padding:4px;
    color:var(--muted); transition:color .2s, transform .15s; min-height:auto;
    display:inline-grid; place-items:center; line-height:1;
}
.fav-btn:hover { color:#e88a9a; transform:scale(1.15); }
.fav-btn.fav-active { color:#e85a7a; }
.fav-btn.fav-active:hover { color:#ff7a9a; }
.fav-btn-sm { font-size:14px; padding:0 3px; min-height:auto; }
.fav-btn-bar { font-size:20px; min-height:auto; }

/* Player bar artwork */
.player-bar #np-art { flex-shrink:0; }

/* ─── Track List (songs table / album / artist) ──────────── */
.track-list { list-style:none; padding:0; margin:16px 0 0; }
.track-item {
    display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:8px;
    cursor:pointer; transition:background .15s;
}
.track-item:hover { background:rgba(255,255,255,.04); }
.track-item.playing { background:rgba(139,224,180,.08); border-left:3px solid var(--ok); }
.track-art { width:40px; height:40px; border-radius:4px; object-fit:cover; flex-shrink:0; }
.track-art-fallback {
    width:40px; height:40px; border-radius:4px; display:flex; align-items:center; justify-content:center;
    font-size:11px; color:rgba(255,255,255,.6); flex-shrink:0;
    background:linear-gradient(135deg,#0a3d4a,#1a6b7a);
}
.track-num { width:22px; text-align:center; color:var(--muted); font-size:12px; flex-shrink:0; }
.track-title {
    flex:1; color:var(--text); font-size:14px; font-weight:500; min-width:0;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.track-artist { color:var(--muted); font-size:13px; max-width:120px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex-shrink:0; }
.track-dur { color:var(--muted); font-size:12px; min-width:38px; text-align:right; flex-shrink:0; }
.player-close {
    width:36px; height:36px; border:none; border-radius:50%;
    background:rgba(255,255,255,.08); color:var(--text); cursor:pointer;
    font-size:20px; display:grid; place-items:center; min-height:36px; padding:0;
}
.player-close:hover { background:rgba(255,154,154,.3); }
@media (max-width:700px) {
    .track-artist { display:none; }
    .track-num { width:18px; font-size:11px; }
    .track-art,.track-art-fallback { width:36px; height:36px; }
    .track-item { padding:6px 8px; gap:6px; }
}

@media (max-width:900px) {
    .quick-grid,.settings-grid { grid-template-columns:1fr; }
}
@media (max-width:700px) {
    .app-shell { grid-template-columns:74px minmax(0,1fr); }
    .rail { padding:14px 0; }
    .brand-mark { width:40px; height:40px; font-size:22px; }
    .nav-stack { gap:20px; }
    .nav-link { font-size:.83rem; }
    .content { padding:24px 16px 46px 18px; }
    .topbar { align-items:flex-start; flex-direction:column; gap:10px; margin-bottom:20px; }
    .auth-grid { grid-template-columns:1fr; }
    .quick-item { grid-template-columns:64px minmax(0,1fr); gap:12px; padding-left:0; padding-right:0; }
    .album-placeholder { width:64px; }
    .panel { border-radius:16px; padding:17px; }
    .shelf { grid-auto-columns:minmax(160px,72vw); }
    dl { grid-template-columns:86px 1fr; }
}
@media (max-width:420px) {
    .app-shell { grid-template-columns:62px minmax(0,1fr); }
    .content { padding-left:12px; padding-right:12px; }
    .nav-link { font-size:.76rem; }
}
.pw-wrap { position:relative; display:block; }
.pw-wrap input { padding-right:48px; }
.pw-toggle {
    position:absolute; right:6px; top:50%; transform:translateY(-50%);
    width:38px; min-height:38px; border:none; border-radius:10px;
    background:rgba(255,255,255,.1); cursor:pointer; font-size:18px;
    display:grid; place-items:center; padding:0;
}
.pw-toggle:hover { background:rgba(255,255,255,.18); }
.data-table { width:100%; border-collapse:collapse; }
.data-table th { text-align:left; padding:10px 12px; border-bottom:2px solid var(--border); color:var(--muted); font-size:.82rem; font-weight:700; text-transform:uppercase; letter-spacing:.04em; }
.data-table td { padding:10px 12px; border-bottom:1px solid var(--border); }
.data-table tr:hover td { background:rgba(255,255,255,.03); }
.table-footer { margin-top:12px; color:var(--muted); font-size:.85rem; }
.play-btn {
    width:36px; height:36px; border-radius:50%; border:1px solid var(--border);
    background:rgba(255,255,255,.08); color:var(--text); cursor:pointer;
    display:grid; place-items:center; font-size:14px; padding:0; min-height:36px;
}
.play-btn:hover { background:var(--ok); color:#000; }
.player-bar {
    position:fixed; bottom:0; left:118px; right:0;
    background:var(--bg-deep); border-top:1px solid var(--border);
    display:flex; align-items:center; padding:10px 16px; gap:12px; z-index:20;
}
.player-bar .np-art { width:48px; height:48px; border-radius:6px; object-fit:cover; flex-shrink:0; }
.player-bar .now-playing { flex:1; min-width:0; overflow:hidden; }
.player-bar .now-playing .np-title,
.player-bar .now-playing strong { display:block; color:var(--text); font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.player-bar .now-playing .np-artist,
.player-bar .now-playing span { display:block; color:var(--muted); font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.player-bar .transport { display:flex; flex-direction:column; align-items:center; gap:4px; }
.player-status { color:var(--muted); font-size:11px; }
.player-controls { display:flex; align-items:center; gap:10px; }
.player-controls span { color:var(--muted); font-size:.82rem; min-width:40px; text-align:center; }
.player-btn {
    width:38px; height:38px; border:none; border-radius:50%;
    background:var(--ok); color:#000; cursor:pointer;
    display:grid; place-items:center; font-size:16px; padding:0;
}
.player-btn:disabled { opacity:.4; cursor:default; }
.player-close {
    width:36px; height:36px; border:none; border-radius:50%;
    background:rgba(255,255,255,.08); color:var(--text); cursor:pointer;
    font-size:20px; display:grid; place-items:center; min-height:36px; padding:0;
}
.player-close:hover { background:rgba(255,154,154,.3); }
.player-bar .seek-row { display:flex; align-items:center; gap:6px; width:100%; }
.time-display { color:var(--muted); font-size:11px; min-width:32px; text-align:center; }

@media (min-width:701px) {
    .player-bar .player-status { display:inline; }
}
@media (max-width:700px) {
    .player-bar { left:62px; gap:8px; padding:8px 12px; }
    .player-bar .player-status { display:none; }
    .player-bar .np-art { width:42px; height:42px; }
}

/* ─── Seek Track (custom progress bar) ───────────────────── */
.seek-track {
    flex:1; width:100%; height:4px; background:var(--border); border-radius:2px;
    position:relative; cursor:pointer; -webkit-tap-highlight-color:transparent;
}
.seek-fill { height:100%; background:var(--ok); border-radius:2px; pointer-events:none; width:0; }
.seek-ball {
    width:14px; height:14px; background:var(--ok); border-radius:50%; position:absolute;
    top:50%; transform:translate(-50%,-50%); left:0; pointer-events:none;
    box-shadow:0 0 4px rgba(139,224,180,.4);
}
.seek-track:active .seek-ball { transform:translate(-50%,-50%) scale(1.25); }
@media (max-width:700px) {
    .seek-track { height:6px; }
    .seek-ball { width:18px; height:18px; }
}

/* ─── Mosaic Tiles (index.php) ─────────────────────────────── */
.shelf-card { cursor:pointer; }
.shelf-card:hover { background:rgba(255,255,255,.04); }
.mosaic-tiles {
    display:grid; grid-auto-flow:column; grid-auto-columns:minmax(200px,240px); gap:18px;
    overflow-x:auto; padding:2px 2px 14px; scroll-snap-type:x proximity;
}
.mosaic-tile-wrap {
    display:block; scroll-snap-align:start; border-radius:16px; overflow:hidden;
    border:1px solid rgba(255,255,255,.08); background:rgba(3,29,37,.5);
    text-decoration:none; color:inherit;
}
.mosaic-tile-wrap:hover { border-color:rgba(255,255,255,.16); }
.mosaic-grid {
    display:grid; grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr;
    aspect-ratio:1; gap:0; overflow:hidden; border-radius:16px 16px 0 0;
}
.mosaic-grid .mosaic-tile {
    aspect-ratio:1; overflow:hidden; display:grid; place-items:center;
    background:linear-gradient(145deg,#48646b,#173b45);
}
.mosaic-grid .mosaic-tile img {
    width:100%; height:100%; object-fit:cover; display:block;
}
.mosaic-grid .mosaic-fallback {
    width:100%; height:100%; background:linear-gradient(145deg,#48646b,#173b45);
}
.mosaic-tile-info { padding:12px 14px; }
.mosaic-tile-info strong { display:block; font-size:1rem; margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mosaic-tile-info small { color:var(--muted); font-size:.85rem; }

/* ─── Playlist Playback Page ───────────────────────────────── */
.playlist-hero {
    display:grid; grid-template-columns:auto 1fr; gap:32px; align-items:start;
    padding-bottom:30px; border-bottom:1px solid var(--border); margin-bottom:30px;
}
.playlist-hero-art { width:280px; flex-shrink:0; }
.playlist-hero-info h1 { margin-top:8px; font-size:clamp(1.5rem,3vw,2.2rem); }
.playlist-meta { color:var(--muted); font-size:.92rem; margin-top:6px; }
.playlist-desc { color:var(--muted); font-size:.88rem; margin-top:10px; line-height:1.5; }
.playlist-actions { display:flex; gap:12px; margin-top:18px; }
.playlist-actions button { min-height:42px; }

/* Track list enhancements */
.track-row { cursor:pointer; }
.track-row:hover td { background:rgba(255,255,255,.04); }
.track-row.playing td { background:rgba(139,224,180,.08); }
.track-row.playing .track-pos { color:var(--ok); font-weight:700; }
.track-row.unmatched { opacity:.7; }
.track-pos { color:var(--muted); font-size:.9rem; min-width:30px; }

/* Match badges */
.match-badge {
    display:inline-block; padding:2px 8px; border-radius:8px; font-size:.75rem;
    font-weight:700; text-transform:uppercase; letter-spacing:.04em;
}
.match-confirmed { background:rgba(139,224,180,.2); color:var(--ok); }
.match-probable { background:rgba(255,215,0,.15); color:#ffd700; }
.match-unmatched { background:rgba(255,255,255,.08); color:var(--muted); }
.match-rejected { background:rgba(255,154,154,.15); color:var(--danger); }

/* Player nav buttons */
.player-nav { display:flex; gap:6px; }
.player-nav-btn {
    width:36px; height:36px; border:none; border-radius:50%;
    background:rgba(255,255,255,.08); color:var(--text); cursor:pointer;
    display:grid; place-items:center; font-size:14px; padding:0; min-height:36px;
}
.player-nav-btn:hover { background:rgba(255,255,255,.16); }

/* Responsive playlist hero */
@media (max-width:700px) {
    .playlist-hero { grid-template-columns:1fr; }
    .playlist-hero-art { width:100%; max-width:280px; margin:0 auto; }
    .mosaic-tiles { grid-auto-columns:minmax(170px,68vw); }
}
