:root {
  --accent: #007aff;
  --main: #fff;
  --card: #fff;
  --label: #000;
  --label2: rgba(60, 60, 67, .6);
  --label3: rgba(60, 60, 67, .3);
  --sep: rgba(60, 60, 67, .2);
  --fill: rgba(118, 118, 128, .12);
  --fill2: rgba(118, 118, 128, .07);
  --bar: rgba(249, 249, 249, .8);
  --folder-back: #3b95ee;
  --folder-front: #6cb5f8;
  --file: #fff;
  --file-edge: rgba(60, 60, 67, .45);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --nav-h: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0a84ff;
    --main: #000;
    --card: #1c1c1e;
    --label: #fff;
    --label2: rgba(235, 235, 245, .6);
    --label3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .65);
    --fill: rgba(118, 118, 128, .24);
    --fill2: rgba(118, 118, 128, .14);
    --bar: rgba(28, 28, 30, .78);
    --folder-back: #2a7fd6;
    --folder-front: #58a8f2;
    --file: #2c2c2e;
    --file-edge: rgba(235, 235, 245, .18);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 17px/1.3 var(--font);
  letter-spacing: -.01em;
  color: var(--label);
  background: var(--main);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
.sym { width: 1em; height: 1em; flex: none; display: block; }

/* ── screen ─────────────────────────────────────────────────── */
#screen { position: fixed; inset: 0; z-index: 100; pointer-events: none; overflow: hidden; }
#screen > div { position: absolute; inset: 0; }
#screen .static {
  inset: -50%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 .7 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: .06;
  animation: static .45s steps(5) infinite;
}
@keyframes static {
  0% { transform: translate(0, 0); } 20% { transform: translate(-4%, 3%); } 40% { transform: translate(3%, -2%); }
  60% { transform: translate(-2%, -4%); } 80% { transform: translate(4%, 2%); }
}
@media (prefers-reduced-motion: reduce) {
  #screen .static { animation: none; }
}

/* ── layout ─────────────────────────────────────────────────── */
.app { height: 100dvh; }
.main { position: relative; height: 100%; background: var(--main); overflow: hidden; }

.navbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  height: calc(var(--nav-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  border-bottom: .5px solid transparent;
  transition: background .2s, border-color .2s;
}
.navbar.scrolled {
  background: var(--bar);
  border-color: var(--sep);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.back {
  grid-column: 1; justify-self: start; display: flex; align-items: center;
  color: var(--accent); white-space: nowrap; max-width: 100%;
  padding: 6px 6px 6px 0; margin-left: -8px;
}
.back[hidden] { display: none; }
.back .sym { width: 26px; height: 26px; }
#back-label { overflow: hidden; text-overflow: ellipsis; }
.nav-title {
  grid-column: 2; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 42vw; opacity: 0; transition: opacity .2s;
}
.navbar.scrolled .nav-title { opacity: 1; }
.nav-actions { grid-column: 3; justify-self: end; display: flex; gap: 4px; }
.nav-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); }
.nav-btn .sym { width: 22px; height: 22px; }

.scroller {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  padding-top: calc(var(--nav-h) + env(safe-area-inset-top));
}
.page { padding: 0 28px 170px; max-width: 920px; margin: 0 auto; }
.page.push { animation: push .4s cubic-bezier(.2, .85, .25, 1); }
.page.pop { animation: pop .4s cubic-bezier(.2, .85, .25, 1); }
@keyframes push { from { transform: translateX(36%); opacity: 0; } }
@keyframes pop { from { transform: translateX(-20%); opacity: 0; } }
.large-title { font: 700 34px/1.15 var(--display); letter-spacing: .01em; margin: 2px 0 16px; }
.large-title:has(+ .tagline) { margin-bottom: 2px; }
.tagline { margin: 0 0 22px; font-size: 17px; color: var(--label2); }

/* ── icons ──────────────────────────────────────────────────── */
.icon { display: contents; }
.cover {
  display: block; object-fit: cover; border-radius: 6px;
  image-rendering: pixelated;
  background: var(--fill);
  box-shadow: 0 0 0 .5px var(--sep), 0 4px 14px rgba(0, 0, 0, .12);
}

/* ── grid view ──────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 26px 12px; padding-top: 4px; }
.tile { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 4px 10px; border-radius: 14px; min-width: 0; transition: transform .15s; }
.tile:active { transform: scale(.96); }
.t-thumb { height: 96px; width: 100%; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 8px; }
.t-thumb .big-folder { width: 94px; }
.t-thumb .big-file { height: 88px; }
.t-thumb .cover { width: 90px; height: 90px; }
.t-name {
  font-size: 13px; font-weight: 500; line-height: 1.25; letter-spacing: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.tile.playing .t-name { color: var(--tint, var(--accent)); }
.sub { font-size: 12px; letter-spacing: 0; color: var(--label2); display: inline-flex; align-items: center; gap: 3px; }
.tile .sub { margin-top: 2px; }
.sub .sym { width: 14px; height: 14px; }
.item.dim .t-thumb, .item.dim .r-thumb { opacity: .45; }

/* ── list view ──────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }
.row {
  position: relative; display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 62px; padding: 6px 10px 6px 4px; border-radius: 10px;
}
.row::after { content: ""; position: absolute; left: 62px; right: 0; bottom: 0; border-bottom: .5px solid var(--sep); }
.row:last-child::after { display: none; }
.row:active { background: var(--fill); }
.r-thumb { width: 44px; height: 44px; flex: none; display: grid; place-items: center; }
.r-thumb .big-folder { width: 42px; }
.r-thumb .big-file { height: 40px; }
.r-thumb .cover { width: 44px; height: 44px; border-radius: 5px; }
.r-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.r-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--label3); }
.chev .sym { width: 14px; height: 14px; }
.num { width: 28px; flex: none; text-align: center; color: var(--label2); font-variant-numeric: tabular-nums; }
.tracks .row { min-height: 54px; }
.tracks .row::after { left: 46px; }
.row.playing .r-name, .row.playing .num { color: var(--tint, var(--accent)); }

/* the "now playing" mark: a little liquid dancer (see DANCER in app.js) */
.eq { display: none; width: 44px; height: 44px; margin: -8px -6px -8px 0; flex: none; color: var(--tint, var(--accent)); }
.playing .eq { display: block; }
.dancer { width: 100%; height: 100%; display: block; overflow: visible; }
.item .dancer .body { filter: url(#blob-flat); } /* small dancer: flat — the shading only shows in the player */

.footer { margin: 0; padding: 20px 4px; text-align: center; font-size: 13px; color: var(--label2); }
.hint { margin: 0 0 18px; padding: 10px 14px; border-radius: 10px; background: var(--fill2); color: var(--label2); font-size: 13px; }
.empty { padding: 60px 0; text-align: center; color: var(--label2); }

/* ── album header ───────────────────────────────────────────── */
.album-head { display: flex; align-items: flex-end; gap: 28px; padding: 6px 0 26px; }
.cover.big { width: min(240px, 36vw); height: auto; aspect-ratio: 1; border-radius: 10px; box-shadow: 0 0 0 .5px var(--sep), 0 14px 40px rgba(0, 0, 0, .22); }
.a-title { font: 700 28px/1.15 var(--display); margin: 0; }
.a-artist { margin: 2px 0 0; font-size: 20px; color: var(--accent); }
.a-info { margin: 6px 0 18px; font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--label2); }
.a-btns { display: flex; gap: 12px; }
.pill {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 130px; height: 44px; padding: 0 20px; border-radius: 12px;
  background: var(--fill); color: var(--accent); font-weight: 600;
}
.pill .sym { width: 16px; height: 16px; }
.pill:active { opacity: .6; }

@media (hover: hover) {
  .tile:hover, .row:hover, .nav-btn:hover { background: var(--fill2); }
}

/* ── mini player ────────────────────────────────────────────── */
.mini {
  position: absolute; z-index: 6; left: 20px; right: 20px; bottom: 20px;
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  height: 64px; padding: 0 10px 0 9px;
  border-radius: 16px; overflow: hidden; cursor: pointer;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: 0 0 0 .5px var(--sep), 0 10px 30px rgba(0, 0, 0, .16);
  animation: rise .4s cubic-bezier(.2, .9, .3, 1.15);
}
.mini[hidden] { display: none; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.mini-icon { width: 46px; height: 46px; flex: none; display: grid; place-items: center; }
.mini-icon .big-file { height: 42px; }
.m-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mini-title { font-size: 15px; font-weight: 600; }
#mini-sub { font-size: 13px; color: var(--label2); }
.m-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; }
.m-btn .sym { width: 24px; height: 24px; }
.m-btn:active { background: var(--fill); }
.m-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--fill); }
.m-prog i { display: block; width: 0; height: 100%; background: var(--tint, var(--accent)); }

/* ── sheets ─────────────────────────────────────────────────── */
.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .4); opacity: 0; transition: opacity .35s; }
.sheet-back.in { opacity: 1; }
.sheet {
  position: fixed; z-index: 41; inset: 0; margin: auto;
  width: min(560px, calc(100vw - 48px)); height: min(740px, calc(100dvh - 64px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 16px; background: var(--card);
  transform: translateY(105vh);
  transition: transform .45s cubic-bezier(.2, .9, .25, 1);
}
.sheet.in { transform: none; }
.sheet-bar {
  flex: none; height: 54px; padding: 0 16px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  border-bottom: .5px solid var(--sep); touch-action: none;
}
.link-btn { justify-self: start; color: var(--accent); font-weight: 600; }
.ql-text {
  flex: 1; margin: 0; padding: 22px 24px 60px; overflow: auto;
  font: 15px/1.65 var(--mono); white-space: pre-wrap; user-select: text;
}

/* player */
.player-sheet { background: #222; color: #fff; }
.player-sheet::before {
  content: ""; position: absolute; inset: -30%;
  background: var(--art) center / cover;
  filter: blur(70px) saturate(1.5) brightness(.55);
}
.player-sheet > * { position: relative; }
.grab { flex: none; height: 46px; display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .45); }
.grab-btn { position: absolute; left: 12px; top: 7px; width: 34px; height: 34px; display: grid; place-items: center; color: rgba(255, 255, 255, .75); }
.grab-btn .sym { width: 22px; height: 22px; }
.p-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 4px 34px 40px; }
.p-art-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.p-art {
  width: min(100%, 44dvh); aspect-ratio: 1; border-radius: 12px; image-rendering: pixelated;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  transition: transform .55s cubic-bezier(.3, 1.35, .5, 1);
}
.player-sheet.paused .p-art { transform: scale(.82); }
.p-meta { margin-top: 26px; display: flex; align-items: center; gap: 12px; }
.p-text { flex: 1; min-width: 0; }
.p-heart .heart { color: rgba(255, 255, 255, .7); width: 44px; height: 44px; margin: 0; }
.p-heart .heart.on { color: #ff375f; }
.p-heart .heart .sym { width: 28px; height: 28px; }
.p-heart .h-count { color: rgba(255, 255, 255, .6); }
.p-title { font-size: 21px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-sub { font-size: 17px; color: rgba(255, 255, 255, .6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-scrub { margin-top: 22px; }
.p-range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer; }
.p-range::-webkit-slider-runnable-track {
  height: 7px; border-radius: 4px;
  background: linear-gradient(rgba(255, 255, 255, .85), rgba(255, 255, 255, .85)) 0 0 / var(--p, 0%) 100% no-repeat, rgba(255, 255, 255, .22);
}
.p-range::-webkit-slider-thumb { -webkit-appearance: none; width: 1px; height: 7px; background: transparent; }
.p-range::-moz-range-track { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .22); }
.p-range::-moz-range-progress { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .85); }
.p-range::-moz-range-thumb { width: 0; border: 0; }
.p-times { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .55); }
.p-ctrls { display: flex; justify-content: center; align-items: center; gap: 44px; margin-top: 22px; }
.p-btn { width: 60px; height: 60px; display: grid; place-items: center; border-radius: 50%; color: #fff; transition: transform .15s; }
.p-btn .sym { width: 34px; height: 34px; }
.p-btn.big .sym { width: 48px; height: 48px; }
.p-btn:active { transform: scale(.88); background: rgba(255, 255, 255, .12); }

/* alert */
.alert-back { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0, 0, 0, .3); animation: fade .2s; }
.alert {
  width: 270px; overflow: hidden; text-align: center; border-radius: 14px;
  background: var(--bar);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  animation: pop-in .3s cubic-bezier(.2, 1.3, .4, 1);
}
.alert strong { display: block; padding: 20px 16px 4px; font-size: 17px; }
.alert p { margin: 0; padding: 0 16px 18px; font-size: 13px; }
.alert button { display: block; width: 100%; height: 44px; text-align: center; border-top: .5px solid var(--sep); color: var(--accent); font-weight: 600; }
@keyframes pop-in { from { transform: scale(1.15); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ── rollout: new dots, locked tracks, votes ─────────────── */
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; vertical-align: 1px; border-radius: 50%; background: var(--accent); }
.item.locked { cursor: default; }
.item.locked .t-thumb, .item.locked .r-thumb, .item.locked .num { opacity: .45; }
.item.locked .r-name, .item.locked .t-name { color: var(--label2); }
.row { cursor: pointer; }
.row:focus-visible, .tile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pill:disabled { color: var(--label2); cursor: default; opacity: 1; }

.heart {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 40px; height: 40px; padding: 0 8px; margin-right: -6px; border-radius: 20px;
  color: var(--label3); font-size: 13px; font-variant-numeric: tabular-nums;
}
.heart .sym { width: 22px; height: 22px; }
.heart.on { color: #ff375f; }
.heart.pop .h-icon { animation: heartpop .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes heartpop { 40% { transform: scale(1.35); } }
.h-count { color: var(--label2); }
.h-count:empty { display: none; }
.vote-hint { display: flex; align-items: center; gap: 8px; }
.vote-hint .sym { width: 15px; height: 15px; color: #ff375f; }
.vote-hint .admin { opacity: .75; }
.share { flex: none; width: 40px; height: 40px; margin-right: -8px; display: grid; place-items: center; border-radius: 20px; color: var(--label3); }
.share .sym { width: 20px; height: 20px; }
@media (hover: hover) { .heart:hover, .share:hover { background: var(--fill2); color: var(--accent); } }
.p-share .share { color: rgba(255, 255, 255, .7); width: 44px; height: 44px; margin: 0; }
.p-share .share .sym { width: 24px; height: 24px; }
.p-share .share:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.toast {
  position: fixed; z-index: 70; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
  padding: 11px 18px; border-radius: 22px; font-size: 15px; font-weight: 600;
  background: var(--bar); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 0 0 .5px var(--sep), 0 10px 30px rgba(0, 0, 0, .18);
  animation: fade .2s; user-select: text;
}
.toast span { overflow-wrap: anywhere; }
.toast .sym { width: 18px; height: 18px; color: var(--accent); }

@media (max-width: 759px) {
  :root { --nav-h: 44px; }
  .page { padding: 0 16px calc(170px + env(safe-area-inset-bottom)); }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 20px 6px; }
  .t-thumb { height: 82px; }
  .t-thumb .big-folder { width: 84px; }
  .t-thumb .big-file { height: 76px; }
  .t-thumb .cover { width: 80px; height: 80px; }
  .album-head { flex-direction: column; align-items: center; text-align: center; gap: 18px; }
  .cover.big { width: min(270px, 70vw); }
  .a-btns { justify-content: center; }
  .pill { flex: 1; min-width: 0; }
  .mini { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); }
  .sheet { inset: auto 0 0 0; margin: 0; width: 100%; height: calc(100dvh - 10px - env(safe-area-inset-top)); border-radius: 12px 12px 0 0; }
  .p-body { padding: 4px 26px calc(34px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .page.push, .page.pop, .mini, .heart.pop .h-icon { animation: none; }
}

/* ── Quick Look-style player ────────────────────────────────── */
.qlp { background: var(--main); }
.qlp-name { max-width: 56vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.qlp-stage {
  flex: 1; min-height: 0; padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; touch-action: pan-y; user-select: none;
}
.qlp-icon .dancer { width: min(300px, 42dvh); height: min(300px, 42dvh); margin-bottom: 10px; }
.qlp-icon .big-file { height: min(190px, 28dvh); margin-bottom: 18px; filter: drop-shadow(0 8px 22px rgba(0, 0, 0, .08)); }
.qlp-file { font-size: 17px; font-weight: 600; max-width: 100%; overflow-wrap: anywhere; }
.qlp-sub { font-size: 13px; color: var(--label2); }
.qlp-controls {
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px 14px; padding: 10px 14px; border-radius: 14px;
  background: var(--fill2); color: var(--label2); font-size: 12px; font-variant-numeric: tabular-nums;
}
.qlp-play { width: 34px; height: 34px; flex: none; display: grid; place-items: center; color: var(--label); }
.qlp-play .sym { width: 22px; height: 22px; }
.qlp-range { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 20px; margin: 0; background: transparent; cursor: pointer; }
.qlp-range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(var(--label2), var(--label2)) 0 0 / var(--p, 0%) 100% no-repeat, var(--fill);
}
.qlp-range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 .5px rgba(0,0,0,.15), 0 2px 6px rgba(0, 0, 0, .25); }
.qlp-range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--fill); }
.qlp-range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--label2); }
.qlp-range::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.qlp-toolbar {
  flex: none; display: flex; justify-content: space-between; align-items: center;
  padding: 4px 12px calc(8px + env(safe-area-inset-bottom)); border-top: .5px solid var(--sep);
}
.qlp .share, .qlp .heart { width: 44px; height: 44px; margin: 0; color: var(--accent); }
.qlp .share .sym { width: 24px; height: 24px; }
.qlp .heart .sym { width: 26px; height: 26px; }
.qlp .heart.on { color: #ff375f; }
.qlp .h-count { color: var(--label2); }
.qlp .p-share .share:hover, .qlp .heart:hover { background: var(--fill2); color: var(--accent); }
.qlp .heart.on:hover { color: #ff375f; }
