/* Donkify - Gilroy, two weights only (400 and 700) */
@font-face {
    font-family: 'gilroy';
    font-style: normal;
    font-weight: 400;
    src: url('/fonts/Gilroy-Light.woff2') format('woff2');
    font-display: swap;
}

@font-face {
    font-family: 'gilroy';
    font-style: normal;
    font-weight: 700;
    src: url('/fonts/Gilroy-ExtraBold.woff2') format('woff2');
    font-display: swap;
}

:root {
    --bg: #121212;
    --bg2: #181818;
    --bg3: #242424;
    --hover: #2a2a2a;
    --fg: #fff;
    --fg2: #b3b3b3;
    --green: #64DF1F;
    --maroon: #5e2222;
    --line: rgba(255, 255, 255, .08);
    --player-h: 76px;
    color-scheme: dark;
}

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

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
    font-family: 'gilroy', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.3;
    color: var(--fg);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul, ol { list-style: none; }
svg { fill: currentColor; }
h1, h2, h3, strong, b { font-weight: 700; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* ---------- loading overlay (the spinning donk) ---------- */
#boot {
    position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
    background: var(--bg); opacity: 0; pointer-events: none; transition: opacity .45s ease-out;
}
#boot img { width: 140px; height: 140px; animation: spin 2s ease infinite; }
body.preload #boot { opacity: 1; pointer-events: auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #boot img { animation: none; } }

/* ---------- top bar ---------- */
#topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
    background: rgba(18, 18, 18, .9);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; flex: none; }
.brand img { width: 32px; height: 32px; }

.search { position: relative; flex: 1; max-width: 420px; margin: 0 auto 0 8px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 22px; height: 22px; transform: translateY(-50%); color: var(--fg2); pointer-events: none; }
.search input {
    width: 100%; height: 42px; padding: 0 16px 0 42px; border: 0; border-radius: 999px;
    background: var(--bg3); color: var(--fg); font: inherit; font-size: 15px;
}
.search input::placeholder { color: var(--fg2); }
.search input:hover { background: var(--hover); }
.search input:focus-visible { outline: 2px solid var(--fg); outline-offset: 0; }

.menu { position: relative; flex: none; }
.menu summary {
    display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px;
    background: var(--bg3); cursor: pointer; list-style: none; user-select: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--hover); }
.avatar {
    display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
    background: var(--green); color: #000; font-weight: 700; font-size: 15px; text-transform: uppercase;
}
.uname { font-size: 14px; font-weight: 700; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 170px; padding: 4px;
    background: #282828; border-radius: 8px; box-shadow: 0 16px 32px rgba(0, 0, 0, .5);
}
.pop button { width: 100%; padding: 11px 12px; border-radius: 4px; text-align: left; font-size: 15px; }
.pop button:hover { background: #3e3e3e; }

/* ---------- layout ---------- */
main { padding-bottom: calc(var(--player-h) + 40px + env(safe-area-inset-bottom)); outline: none; }
.wrap { max-width: 1500px; margin: 0 auto; padding: 0 16px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0 16px; }
.chip { padding: 7px 14px; border-radius: 999px; background: var(--bg3); font-size: 14px; font-weight: 700; }
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--fg); color: #000; }
.spacer { flex: 1; }
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px 8px 12px; border-radius: 999px;
    background: var(--bg3); font-size: 14px; font-weight: 700;
}
.btn:hover { background: var(--hover); }
.btn svg { width: 20px; height: 20px; }
.btn.green { background: var(--green); color: #000; }
.btn.green:hover { filter: brightness(1.08); }

h2.sec { font-size: 22px; margin: 8px 0 14px; }
.sec-gap { height: 20px; }
.empty { color: var(--fg2); padding: 32px 0; }

/* ---------- cards ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 24px 20px; } }

.card { position: relative; cursor: pointer; min-width: 0; margin-bottom: 8px;   border-radius: 8px; background: var(--bg2); transition: background .2s; }
.card:hover { background: #262626; }
.art {
    position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--bg3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.art img { width: 100%; height: 100%; object-fit: cover; }
.art.mosaic { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.art.blank { display: grid; place-items: center; }
.art.blank img { width: 46%; height: auto; opacity: .85; }

.pill {
    position: absolute; left: 8px; top: 8px; padding: 3px 8px; border-radius: 999px;
    background: var(--green); color: #000; font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.fab {
    position: absolute; right: 8px; bottom: 8px; width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center; background: var(--green); color: #000;
    opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
    box-shadow: 0 8px 12px rgba(0, 0, 0, .35);
}
.fab svg { width: 26px; height: 26px; }
.fab:hover { transform: scale(1.06); }
.card:hover .fab, .fab:focus-visible { opacity: 1; transform: none; }
@media (hover: none) { .fab { opacity: 1; transform: none; width: 40px; height: 40px; } }

.ct { display: block; margin-top: 12px; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs { margin-top: 4px; font-size: 13px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.now .ct { color: var(--green); }

/* ---------- album / playlist page ---------- */
.ahead { background: linear-gradient(180deg, var(--c, var(--maroon)) 0%, var(--bg) 100%); padding: 20px 0 8px; margin-top: -1px; }
.ahead-in { display: flex; align-items: flex-end; gap: 24px; }
.ahead .art { width: min(232px, 56vw); flex: none; box-shadow: 0 16px 48px rgba(0, 0, 0, .55); }
.ahead .txt { min-width: 0; padding-bottom: 4px; }
.kind { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.ahead h1 { font-size: clamp(28px, 6vw, 60px); line-height: 1.05; margin: 6px 0 10px; overflow-wrap: anywhere; }
.desc { color: #ddd; font-size: 15px; max-width: 60ch; margin-bottom: 10px; }
.by { font-size: 14px; color: #ddd; }
.by b { color: var(--fg); }
.back { display: inline-flex; align-items: center; gap: 2px; padding: 4px 10px 4px 2px; margin: 0 0 12px -6px; border-radius: 999px; font-size: 14px; font-weight: 700; }
.back svg { width: 26px; height: 26px; }
.back:hover { background: rgba(255, 255, 255, .12); }
@media (max-width: 640px) {
    .ahead-in { flex-direction: column; align-items: flex-start; gap: 16px; }
    .ahead .art { width: min(232px, 62vw); }
}

.actions { display: flex; align-items: center; gap: 16px; padding: 18px 0 10px; }
.bigplay {
    width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
    background: var(--green); color: #000; transition: transform .15s;
}
.bigplay:hover { transform: scale(1.06); }
.bigplay:disabled { opacity: .4; cursor: default; transform: none; }
.bigplay svg { width: 32px; height: 32px; }

.tracks { margin-top: 4px; }
.row {
    display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px;
    width: 100%; padding: 8px 12px; border-radius: 6px; text-align: left;
}
.row.thumbs { grid-template-columns: 36px 44px minmax(0, 1fr) auto; }
.row.res { grid-template-columns: 44px minmax(0, 1fr) auto; }
.row:hover { background: rgba(255, 255, 255, .08); }
.row .meta { min-width: 0; }
.row .t { display: block; font-size: 16px; color: var(--fg); font-weight: 700;white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .a { display: block; margin-top: 2px; font-size: 13px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .thumb { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; background: var(--bg3); }
.row .dur { font-size: 13px; color: var(--fg2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .idx { display: grid; place-items: center; color: var(--fg2); font-variant-numeric: tabular-nums; height: 20px; }
.row .eq { display: none; align-items: flex-end; gap: 2px; height: 14px; }
.row .eq i { display: block; width: 3px; height: 4px; background: var(--green); animation: eq 0.9s ease-in-out infinite; }
.row .eq i:nth-child(2) { animation-delay: .2s; }
.row .eq i:nth-child(3) { animation-delay: .4s; }
.row.on .t { color: var(--green); }
.row.on .n { display: none; }
.row.on .eq { display: inline-flex; }
.row.on:not(.playing) .eq i { animation-play-state: paused; height: 10px; }
.tag { display: inline-block; margin-left: 8px; padding: 2px 6px; border-radius: 999px; background: var(--green); color: #000; font-size: 9px; font-weight: 700; vertical-align: 2px; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 14px; } }

/* ---------- player ---------- */
.player {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px;
    min-height: var(--player-h); padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg2); border-top: 1px solid var(--line);
}
.p-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.p-info img { width: 54px; height: 54px; border-radius: 4px; object-fit: cover; background: var(--bg3); flex: none; }
.p-text { display: flex; flex-direction: column; min-width: 0; }
.p-text a { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-text a:hover { text-decoration: underline; }
.p-text span { font-size: 12px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.p-controls { display: flex; align-items: center; gap: 6px; }
.p-controls button { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--fg2); }
.p-controls button svg { width: 24px; height: 24px; }
.p-controls button:hover:not(:disabled) { color: var(--fg); }
.p-controls button:disabled { opacity: .35; cursor: default; }
.p-controls .main { width: 44px; height: 44px; background: var(--fg); color: #000; }
.p-controls .main:hover:not(:disabled) { color: #000; transform: scale(1.06); }
.p-controls .main svg { width: 28px; height: 28px; }
.p-controls .auto { position: relative; margin-left: 4px; }
.p-controls .auto[aria-pressed="true"] { color: var(--green); }
.p-controls .auto[aria-pressed="true"]::after {
    content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px;
    border-radius: 50%; background: var(--green);
}

.p-time { justify-self: end; display: flex; gap: 8px; font-size: 12px; color: var(--fg2); font-variant-numeric: tabular-nums; }
.p-time span + span::before { content: "/"; margin-right: 8px; }

.seek {
    -webkit-appearance: none; appearance: none; position: absolute; left: 0; right: 0; top: -6px;
    width: 100%; height: 12px; margin: 0; background: transparent; cursor: pointer; --p: 0%;
}
.seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--fg) var(--p), #4d4d4d var(--p)); }
.seek::-moz-range-track { height: 4px; border-radius: 2px; background: #4d4d4d; }
.seek::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--fg); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: #fff; opacity: 0; border: 0; }
.seek::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; opacity: 0; }
.seek:hover::-webkit-slider-runnable-track, .seek:focus-visible::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--green) var(--p), #4d4d4d var(--p)); }
.seek:hover::-moz-range-progress, .seek:focus-visible::-moz-range-progress { background: var(--green); }
.seek:hover::-webkit-slider-thumb, .seek:focus-visible::-webkit-slider-thumb { opacity: 1; }
.seek:hover::-moz-range-thumb, .seek:focus-visible::-moz-range-thumb { opacity: 1; }
.seek:focus-visible { outline: none; }
@media (hover: none) {
    .seek::-webkit-slider-thumb { opacity: 1; width: 10px; height: 10px; margin-top: -3px; }
    .seek::-moz-range-thumb { opacity: 1; width: 10px; height: 10px; }
}

@media (max-width: 760px) {
    .player { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding-left: 12px; padding-right: 8px; }
    .p-time { display: none; }
    .p-info img { width: 46px; height: 46px; }
    .p-controls { gap: 0; }
    .p-controls button { width: 36px; height: 36px; }
    .p-controls .main { width: 42px; height: 42px; }
    .p-controls .auto { margin-left: 0; }
    .brand span { display: none; }
    .uname { display: none; }
    .menu summary { padding-right: 4px; }
    .search { margin-left: 0; }
}

/* ---------- toast ---------- */
#toast {
    position: fixed; left: 50%; bottom: calc(var(--player-h) + 20px + env(safe-area-inset-bottom)); z-index: 40;
    transform: translate(-50%, 16px); opacity: 0; pointer-events: none; max-width: min(92vw, 460px);
    padding: 11px 18px; border-radius: 8px; background: #fff; color: #000; font-size: 14px; font-weight: 700;
    transition: opacity .2s, transform .2s; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- login ---------- */
body.login main { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .box { width: min(600px, 100%); text-align: center; }
.login h1.brand { justify-content: center; font-size: 34px; margin-bottom: 28px; }
.login h1.brand img { width: 56px; height: 56px; }
.login h2 { font-size: 24px; margin-bottom: 18px; }
.login p { color: var(--fg2); }
.login .msg { margin-top: 16px; line-height: 1.45; }

.names { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.name {
    display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 12px 18px;
    border-radius: 12px; background: var(--bg2); transition: background .2s, transform .15s;
}
.name:hover:not(:disabled) { background: #282828; transform: translateY(-2px); }
.name:disabled { opacity: .45; cursor: default; }
.name .avatar { width: 64px; height: 64px; font-size: 28px; }
.name .nm { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; line-height: 1.2; }
.name .lk { font-size: 12px; color: var(--fg2); min-height: 14px; font-variant-numeric: tabular-nums; }

.q { font-size: 22px; line-height: 1.25; margin: 4px 0 18px; }
.timer { height: 8px; border-radius: 4px; background: var(--bg3); overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: var(--green); transform-origin: left center; }
.timer.low i { background: #ff5252; }
.secs { margin-top: 8px; font-size: 14px; color: var(--fg2); font-variant-numeric: tabular-nums; }
.ops { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }
.op {
    flex: 1 1 0; max-width: 100px; aspect-ratio: 1; padding: 8px; border-radius: 12px; background: var(--bg2);
    border: 2px solid transparent; transition: background .15s, border-color .15s, transform .1s;
}
.op img { width: 100%; height: 100%; object-fit: contain; }
.op:hover:not(:disabled) { background: #282828; transform: translateY(-2px); }
.op:disabled { cursor: default; }
.op.picked { border-color: var(--green); background: #282828; }

.big { font-size: 54px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 6px 0 10px; line-height: 1; }
.lead { font-size: 20px; font-weight: 700; margin-bottom: 4px; color: var(--fg); }
.actions-row { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.btn-main {
    padding: 13px 30px; border-radius: 999px; background: var(--green); color: #000; font-weight: 700; font-size: 16px;
}
.btn-main:hover { filter: brightness(1.08); }
.btn-ghost { padding: 13px 22px; border-radius: 999px; background: var(--bg3); font-weight: 700; font-size: 16px; }
.btn-ghost:hover { background: var(--hover); }
