/* Preferences UI — shared primitives for the Settings (#/settings) and Admin
   (#/stats) pages. Same visual family as css/now-playing.css. */
:root { --pf-max: 760px; --pf-surface: #181818; --pf-raised: rgba(255,255,255,.06); --pf-line: rgba(255,255,255,.08); --pf-bad: #ff5c5c; }

.pf-page { width: 100%; max-width: var(--pf-max); margin: 0 auto; padding: 24px 16px calc(24px + var(--player-height, 88px) + var(--bottom-nav-height, 0px)); color: #fff; }
.pf-page.pf-admin { --pf-max: 1200px; }
.pf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.pf-head h1 { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.15; }
.pf-head .pf-sub { margin: 6px 0 0; font-size: 13px; color: rgba(255,255,255,.55); }
.pf-head-actions { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(255,255,255,.55); }

.pf-section { margin: 0 0 28px; scroll-margin-top: calc(var(--header-height, 64px) + 56px); }
.pf-section > h2 { margin: 0 0 8px 16px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.45); }
.pf-group { background: var(--pf-surface); border-radius: 20px; overflow: hidden; }

.pf-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; min-height: 56px; padding: 14px 16px; border-top: 1px solid var(--pf-line); }
.pf-row:first-child { border-top: 0; }
.pf-row-label { font-size: 15px; font-weight: 500; line-height: 1.3; }
.pf-row-sub { margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: rgba(255,255,255,.55); }
.pf-row-value { margin: 4px 0 0; font-size: 13px; color: rgba(255,255,255,.72); font-variant-numeric: tabular-nums; }
.pf-row[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.pf-row-ctl { display: flex; align-items: center; gap: 8px; }

.pf-switch { position: relative; width: 51px; height: 31px; padding: 0; border: 0; border-radius: 16px; background: rgba(255,255,255,.18); cursor: pointer; flex: none; transition: background .2s ease; }
.pf-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); transition: transform .15s ease; }
.pf-switch[aria-checked="true"] { background: var(--np-accent, #e0e0e0); }
.pf-switch[aria-checked="true"]::after { transform: translateX(20px); }

.pf-seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--pf-raised); }
.pf-seg button { min-width: 52px; height: 34px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: rgba(255,255,255,.65); font: 600 13px/1 inherit; cursor: pointer; }
.pf-seg button[aria-checked="true"] { background: #fff; color: #000; }

.pf-btn { height: 40px; padding: 0 16px; border: 0; border-radius: 20px; background: var(--pf-raised); color: #fff; font: 600 14px/1 inherit; cursor: pointer; white-space: nowrap; transition: background .15s ease, transform .12s ease; }
.pf-btn:hover { background: rgba(255,255,255,.12); }
.pf-btn:active { transform: scale(.96); }
.pf-btn:disabled { opacity: .5; cursor: default; }
.pf-btn-danger { color: var(--pf-bad); background: rgba(255,92,92,.12); }
.pf-btn-danger:hover { background: rgba(255,92,92,.2); }
.pf-btn-ghost { background: transparent; color: rgba(255,255,255,.7); }

.pf-details { padding: 0 16px 14px; }
.pf-details summary { cursor: pointer; font-size: 13px; color: rgba(255,255,255,.55); list-style: none; }
.pf-details summary::-webkit-details-marker { display: none; }
.pf-details summary::before { content: '▸ '; }
.pf-details[open] summary::before { content: '▾ '; }
.pf-details table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 13px; }
.pf-details td { padding: 6px 0; border-top: 1px solid var(--pf-line); color: rgba(255,255,255,.72); }
.pf-details td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.pf-empty { padding: 32px 16px; text-align: center; color: rgba(255,255,255,.6); font-size: 14px; }
.pf-empty .pf-btn { margin-top: 14px; }
.pf-skel { border-radius: 12px; background: linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,255,255,.12), rgba(255,255,255,.06)); background-size: 200% 100%; animation: np-shimmer 1.4s ease infinite; }
.pf-skel-row { height: 56px; margin-bottom: 1px; border-radius: 0; }

.pf-switch:focus-visible, .pf-seg button:focus-visible, .pf-btn:focus-visible, .pf-details summary:focus-visible { outline: 2px solid var(--np-accent, #e0e0e0); outline-offset: 2px; }

@media (max-width: 600px) {
    .pf-row { grid-template-columns: 1fr; }
    .pf-row-ctl { justify-content: flex-start; }
    .pf-row:has(.pf-switch) { grid-template-columns: minmax(0, 1fr) auto; }
}

/* ── Admin page ─────────────────────────────────────────────────── */
.pf-subnav { position: sticky; top: var(--header-height, 64px); z-index: 3; display: flex; gap: 6px; padding: 8px 0 12px; margin-bottom: 8px; background: linear-gradient(#0a0a0a 70%, transparent); }
.pf-subnav a { height: 34px; padding: 0 14px; border-radius: 17px; background: var(--pf-raised); color: rgba(255,255,255,.7); font: 600 13px/34px inherit; text-decoration: none; }
.pf-subnav a:hover { color: #fff; background: rgba(255,255,255,.12); }
.pf-spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: np-spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }

.pf-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--pf-line); border-radius: 20px; overflow: hidden; }
.pf-kpi { background: var(--pf-surface); padding: 18px 16px; min-width: 0; }
.pf-kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-kpi.is-bad .pf-kpi-value { color: var(--pf-bad); }
.pf-kpi-label { margin-top: 6px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.pf-kpi-sub { margin-top: 2px; font-size: 12px; color: rgba(255,255,255,.45); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pf-table-wrap { overflow-x: auto; }
.pf-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pf-table th, .pf-table td { padding: 12px 16px; text-align: left; border-top: 1px solid var(--pf-line); white-space: nowrap; }
.pf-table th { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.45); border-top: 0; }
.pf-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pf-table .pf-bar-cell { position: relative; }
.pf-table .pf-bar-cell::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: calc(var(--pf-frac, 0) * 100%); background: color-mix(in srgb, var(--np-accent, #e0e0e0) 18%, transparent); border-radius: 4px; }
.pf-table .pf-bar-cell span { position: relative; }
.pf-table td.is-bad { color: var(--pf-bad); }

.pf-rank { display: grid; grid-template-columns: 28px 44px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; border: 0; border-top: 1px solid var(--pf-line); background: transparent; color: #fff; text-align: left; font: inherit; }
.pf-rank:first-child { border-top: 0; }
button.pf-rank { cursor: pointer; }
button.pf-rank:hover { background: rgba(255,255,255,.04); }
.pf-rank-idx { font-size: 13px; color: rgba(255,255,255,.45); font-variant-numeric: tabular-nums; }
.pf-rank-art { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #282828; }
.pf-rank-avatar { width: 44px; height: 44px; border-radius: 50%; background: color-mix(in srgb, var(--np-accent, #e0e0e0) 30%, #282828); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.pf-rank-text { min-width: 0; }
.pf-rank-title { display: block; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-rank-sub { display: block; font-size: 13px; color: rgba(255,255,255,.55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-rank-bar { display: block; height: 3px; margin-top: 6px; border-radius: 2px; background: var(--pf-raised); overflow: hidden; }
.pf-rank-bar::after { content: ''; display: block; height: 100%; width: calc(var(--pf-frac, 0) * 100%); background: var(--np-accent, #e0e0e0); }
.pf-rank-num { font-size: 14px; font-variant-numeric: tabular-nums; color: rgba(255,255,255,.72); text-align: right; white-space: nowrap; }
.pf-rank[aria-expanded="true"] { background: rgba(255,255,255,.04); }

.pf-expand { padding: 4px 16px 16px; border-top: 1px solid var(--pf-line); }
.pf-expand[hidden] { display: none; }
.pf-expand-inner { background: var(--pf-raised); border-radius: 14px; padding: 16px; display: grid; gap: 16px; }
.pf-expand h4 { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.45); }
.pf-expand-profile { margin: 0; font-size: 13px; color: rgba(255,255,255,.65); }
.pf-expand-charts { display: grid; grid-template-columns: 1fr; gap: 16px; }
.pf-expand-songs { margin: 0; padding: 0; list-style: none; font-size: 14px; }
.pf-expand-songs li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--pf-line); }
.pf-expand-songs li:first-child { border-top: 0; }
.pf-expand-songs span:last-child { color: rgba(255,255,255,.55); font-variant-numeric: tabular-nums; }

.pf-bars { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.pf-bars div { flex: 1; position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.pf-bars div::before { content: ''; display: block; height: calc(var(--pf-frac, 0) * 100%); min-height: 2px; border-radius: 2px 2px 0 0; background: var(--np-accent, #e0e0e0); opacity: .85; }
.pf-bars div span { position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; font-size: 10px; text-align: center; color: rgba(255,255,255,.45); }
.pf-bars-wrap { padding-bottom: 18px; }

.pf-skel-kpi { height: 92px; border-radius: 0; }
.pf-skel-table { height: 200px; }

@media (min-width: 600px) {
    .pf-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .pf-expand-charts { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
    .pf-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 599px) {
    .pf-subnav { display: none; }
}
