:root {
  color-scheme: dark light;
  --bg: #111317;
  --bg-elev: #1a1d23;
  --bg-elev-2: #232730;
  --fg: #eef0f3;
  --muted: #9aa1ad;
  --line: #2b3039;
  --accent: #5eb1ff;
  --accent-fg: #06121f;
  --danger: #ff6b6b;
  --ok: #4cd18b;
  --warn: #f2b84b;
  --radius: 14px;
  --tabbar-h: 58px;
  --mini-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7f9;
    --bg-elev: #ffffff;
    --bg-elev-2: #eceef2;
    --fg: #14171c;
    --muted: #616a77;
    --line: #dde1e7;
    --accent: #0a6fd6;
    --accent-fg: #ffffff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }

.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.error { color: var(--danger); min-height: 1.2em; font-size: 14px; }
.ellipsis { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- login ---- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; display: grid; gap: 14px; text-align: center; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-logo { margin: 0 auto; border-radius: 18px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.device-panel { display: grid; gap: 8px; justify-items: center; }
.device-panel img { width: 232px; height: 232px; border-radius: 12px; background: #fff; image-rendering: pixelated; }
.device-code { margin: 0; font: 700 28px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }
.device-panel p { margin: 0; }
.code-input { font: 600 22px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; letter-spacing: .1em; text-transform: uppercase; text-align: center; }
.approve-code { font: 700 32px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; text-align: center; margin: 4px 0; }
.warning { color: var(--warn); font-size: 14px; margin: 0; }
.scanner { position: fixed; inset: 0; z-index: 40; background: #000; display: grid; place-items: center; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner-frame { position: relative; width: min(70vw, 70vh); aspect-ratio: 1; border: 3px solid rgba(255, 255, 255, .85); border-radius: 22px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
.scanner-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(20px + var(--safe-b)); display: grid; gap: 12px; justify-items: center; color: #fff; text-align: center; }
.scanner-bar p { margin: 0; }

.field { display: grid; gap: 6px; text-align: left; font-size: 14px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.field select { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; font-size: 16px; }
.field input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-size: 16px; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn { padding: 11px 16px; border-radius: 12px; background: var(--bg-elev-2); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.btn svg { width: 18px; height: 18px; }

/* ---- layout ---- */
.app { min-height: 100%; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar-title { flex: 1; margin: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 50%; flex: none; }
.icon-btn:active { background: var(--bg-elev-2); }
#settings-button { color: var(--muted); }
#settings-button.active { color: var(--accent); }
.badge { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--bg-elev-2); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--danger); }

.view { padding: 12px 16px calc(var(--tabbar-h) + var(--mini-h) + var(--safe-b) + 24px); outline: none; max-width: 980px; margin: 0 auto; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: color-mix(in srgb, var(--bg-elev) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar a { display: grid; place-items: center; align-content: center; gap: 2px; font-size: 11px; color: var(--muted); }
.tabbar a.active { color: var(--accent); }
.tabbar svg { width: 22px; height: 22px; }

/* ---- lists ---- */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; min-height: 56px; }
.row:active { background: var(--bg-elev); }
.row .grow { flex: 1; min-width: 0; }
.row .num { width: 26px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; flex: none; }
.row .dur { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.row.playing .title { color: var(--accent); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--bg-elev-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); flex: none; }
img.avatar { object-fit: cover; }
.avatar.big { width: 104px; height: 104px; font-size: 40px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.artist-head { display: flex; align-items: center; gap: 18px; margin: 6px 0 4px; }
.artist-head h2 { margin: 0 0 4px; font-size: 22px; line-height: 1.2; }
.artist-head p { margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 18px 14px; }
.card { display: grid; gap: 6px; text-align: left; min-width: 0; }
.card .art { width: 100%; aspect-ratio: 1; }
.card .title { font-size: 14px; font-weight: 600; }
.card .sub { font-size: 13px; }

.art { border-radius: 10px; background: var(--bg-elev-2) center / cover no-repeat; object-fit: cover; display: block; }
.art.small { width: 44px; height: 44px; border-radius: 8px; flex: none; }
.art.large { width: min(100%, 360px, 40vh); aspect-ratio: 1; height: auto; border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); margin: 0 auto; }
img.art:not([src]), img.art[src=""] { visibility: hidden; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.empty svg { width: 42px; height: 42px; margin-bottom: 8px; opacity: .7; }
.spinner { width: 28px; height: 28px; margin: 40px auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.album-head { display: grid; grid-template-columns: 132px 1fr; gap: 16px; align-items: end; margin-bottom: 14px; }
.album-head .art { width: 132px; height: 132px; }
.album-head h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.2; }
.album-head p { margin: 0; }
.actions { display: flex; gap: 10px; margin: 12px 0 6px; flex-wrap: wrap; }

.search-box { position: sticky; top: calc(64px + var(--safe-t)); z-index: 4; background: var(--bg); padding-bottom: 8px; }
.search-box input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg); font-size: 16px; }

.card-box { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; margin-bottom: 14px; }
.card-box h3 { margin: 0; font-size: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.lib-row { display: flex; gap: 10px; align-items: center; }
.lib-row .grow { flex: 1; min-width: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }

/* ---- radio & podcasts ---- */
.segmented { display: inline-flex; background: var(--bg-elev-2); border-radius: 10px; padding: 3px; margin: 2px 0 12px; }
.segmented a, .segmented button { padding: 7px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.segmented .on { background: var(--bg-elev); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: 999px; background: var(--bg-elev-2); color: var(--muted); font-size: 14px; font-weight: 600; }
.chip.on { background: var(--accent); color: var(--accent-fg); }
.logo { width: 48px; height: 48px; border-radius: 10px; background: var(--bg-elev-2) center / contain no-repeat; object-fit: contain; flex: none; display: grid; place-items: center; color: var(--muted); }
img.logo { background: #fff; }
.logo svg { width: 22px; height: 22px; }
.star { width: 44px; height: 44px; display: inline-grid; place-items: center; flex: none; color: var(--muted); }
.star[aria-pressed="true"] { color: var(--warn); }
.star svg { width: 22px; height: 22px; }
.star[aria-pressed="true"] svg path { fill: currentColor; }
.row .live-tag { font-size: 11px; font-weight: 700; color: var(--danger); letter-spacing: .04em; flex: none; }
.podcast-head { display: grid; grid-template-columns: 132px 1fr; gap: 16px; align-items: end; margin-bottom: 10px; }
.podcast-head .art { width: 132px; height: 132px; }
.podcast-head h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.2; }
.podcast-head p { margin: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; cursor: pointer; }
.clamp.open { -webkit-line-clamp: unset; }
.episode .meta { display: flex; gap: 8px; align-items: center; }
.progress-mini { display: inline-block; width: 46px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; vertical-align: middle; }
.progress-mini span { display: block; height: 100%; background: var(--accent); }
.player.live .seek, .player.live .times { visibility: hidden; }
.mini-player.live .mini-progress { display: none; }
.live-badge { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .06em; color: #fff; background: var(--danger); padding: 2px 7px; border-radius: 5px; vertical-align: 2px; margin-right: 6px; }

/* ---- mini player ---- */
.mini-player { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 6px); z-index: 7; height: var(--mini-h); display: flex; align-items: center; gap: 4px; padding: 0 6px 0 8px; background: var(--bg-elev-2); border-radius: 14px; box-shadow: 0 8px 26px rgba(0, 0, 0, .3); overflow: hidden; max-width: 980px; margin: 0 auto; }
.mini-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; height: 100%; }
.mini-text { min-width: 0; display: grid; font-size: 14px; }
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: transparent; }
.mini-progress span { display: block; height: 100%; width: 0; background: var(--accent); }

/* ---- full player ---- */
.player { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; animation: slideup .22s ease-out; }
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } }
/* minmax(0, 1fr): long titles (white-space: nowrap) must not widen the column past the screen. */
.player-inner { min-height: 100%; width: 100%; max-width: 480px; margin: 0 auto; padding: calc(8px + var(--safe-t)) calc(22px + var(--safe-r)) calc(24px + var(--safe-b)) calc(22px + var(--safe-l)); display: grid; grid-template-columns: minmax(0, 1fr); align-content: center; gap: 18px; }
.player-inner > * { min-width: 0; }
.player-close { justify-self: center; }
.player-art-wrap { display: grid; place-items: center; }
.player-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; min-width: 0; }
.player-controls > * { min-width: 0; }
.player-meta { text-align: center; }
.player-meta h2 { margin: 0 0 4px; font-size: 21px; }
.player-meta p { margin: 0; }
.player-extra { position: relative; display: flex; justify-content: center; align-items: center; min-height: 32px; }
.player-extra #player-status { position: absolute; right: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--bg-elev-2); color: var(--muted); font-size: 13px; font-weight: 600; }
.pill svg { width: 16px; height: 16px; }
.pill[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }

/* Lyrics take the artwork's place. */
.player-art-wrap { position: relative; }
.lyrics { display: none; position: relative; width: 100%; height: min(40vh, 420px); overflow-y: auto; overscroll-behavior: contain; text-align: center;
  padding: calc(min(40vh, 420px) * .42) 6px; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent, #000 16%, #000 84%, transparent); mask-image: linear-gradient(transparent, #000 16%, #000 84%, transparent); }
.lyrics::-webkit-scrollbar { display: none; }
.player.lyrics-on #player-art { display: none; }
.player.lyrics-on .lyrics { display: block; }
.lyric { margin: 0; padding: 5px 2px; font-size: 19px; line-height: 1.32; font-weight: 650; color: var(--fg); opacity: .32; transition: opacity .25s, transform .25s; overflow-wrap: anywhere; }
.lyrics.synced .lyric { cursor: pointer; }
.lyric.on { opacity: 1; transform: scale(1.04); }
.lyric.gap { opacity: .22; }
.lyrics:not(.synced) .lyric { opacity: .85; font-size: 17px; font-weight: 500; }
.lyrics-msg { margin: 0; padding: 0 12px; }
.player-extra { gap: 8px; }
.lyrics-mode span { min-width: 3.6em; text-align: left; }

/* Blurred, slowly drifting cover behind the lyrics. */
.player::before { content: ''; position: fixed; inset: -60px; z-index: 0; pointer-events: none; background: var(--art, none) center / cover no-repeat;
  filter: blur(46px) saturate(1.5); opacity: 0; transition: opacity .6s ease; }
.player.lyrics-on::before { opacity: .38; animation: drift 28s ease-in-out infinite alternate; }
.player-inner { position: relative; z-index: 1; }
@keyframes drift { from { transform: scale(1.08) rotate(0deg); } to { transform: scale(1.22) rotate(4deg) translate(2%, -2%); } }

/* Synced views: other lines fade and blur with their distance from the current one. */
.lyrics.synced .lyric { transition: opacity .35s ease, transform .35s cubic-bezier(.2, .8, .2, 1.2), filter .35s ease, color .35s ease; transform-origin: center; }
.lyrics.mode-line .lyric[data-d="2"], .lyrics.mode-karaoke .lyric[data-d="2"] { filter: blur(.6px); }
.lyrics.mode-line .lyric[data-d="3"], .lyrics.mode-karaoke .lyric[data-d="3"] { filter: blur(1.2px); opacity: .24; }
.lyrics.mode-line .lyric[data-d="4"], .lyrics.mode-karaoke .lyric[data-d="4"] { filter: blur(1.8px); opacity: .18; }
.lyrics.mode-line .lyric.on { text-shadow: 0 0 22px color-mix(in srgb, var(--accent) 55%, transparent); }

/* Palavra: the current line's words fill left→right as they are sung, with a small pop. */
.lyric .w { display: inline-block; }
.lyrics.mode-karaoke .lyric.on { opacity: 1; transform: scale(1.06); }
@supports ((-webkit-background-clip: text) or (background-clip: text)) and (color: color-mix(in srgb, red 50%, blue)) {
  .lyrics.mode-karaoke .lyric.on .w {
    --p: 0;
    color: transparent; -webkit-background-clip: text; background-clip: text;
    background-image: linear-gradient(90deg, var(--fg) 0, var(--fg) calc(var(--p) * 100% - 4%),
      color-mix(in srgb, var(--fg) 30%, transparent) calc(var(--p) * 100% + 4%));
  }
}
.lyrics.mode-karaoke .lyric.on .w.sung { animation: pop .42s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { 40% { transform: translateY(-3px) scale(1.07); } }

/* Foco: only the current line, large, with its neighbours faint; lines glide in. */
.lyrics.mode-focus .lyric { opacity: 0; filter: blur(4px); transform: scale(.92); }
.lyrics.mode-focus .lyric[data-d="1"] { opacity: .3; filter: blur(1px); }
.lyrics.mode-focus .lyric.on { opacity: 1; filter: none; transform: scale(1.28); padding-block: 18px; animation: glide .5s cubic-bezier(.2, .8, .2, 1); }
@keyframes glide { from { transform: translateY(18px) scale(1.1); opacity: .3; } }

/* Texto: everything readable, current line tinted, no auto-scroll. */
.lyrics.mode-text { -webkit-mask-image: none; mask-image: none; padding-block: 12px; }
.lyrics.mode-text .lyric { opacity: .78; font-size: 17px; font-weight: 550; }
.lyrics.mode-text .lyric.on { opacity: 1; color: var(--accent); transform: none; }

/* Instrumental breaks: three dots that pulse while it lasts. */
.dots { display: inline-flex; gap: 7px; padding: 6px 0; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .5; }
.lyric.on .dots i { animation: dot 1.2s ease-in-out infinite; }
.lyric.on .dots i:nth-child(2) { animation-delay: .2s; }
.lyric.on .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 100% { transform: scale(.7); opacity: .4; } 50% { transform: scale(1.25); opacity: 1; } }

/* Switching views cross-fades. */
.lyrics.mode-changed { animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .player.lyrics-on::before, .lyrics .lyric, .lyrics .w, .dots i, .lyrics.mode-changed { animation: none !important; transition: none !important; }
}

/* ---- sort bar ---- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 2px 0 12px; }
.toolbar.end { justify-content: flex-end; }
.toolbar .segmented { margin: 0; }
.sort-bar { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.sort-select { position: relative; display: inline-flex; align-items: center; background: var(--bg-elev-2); border-radius: 10px; color: var(--muted); }
.sort-select svg { position: absolute; left: 10px; width: 16px; height: 16px; pointer-events: none; }
.sort-select select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 14px; font-weight: 600; padding: 8px 12px 8px 32px; border-radius: 10px; cursor: pointer; }
.sort-select select:focus-visible { outline: 2px solid var(--accent); }
.sort-select option { color: initial; }
.sort-dir { display: inline-flex; align-items: center; gap: 5px; padding: 8px 12px; border-radius: 10px; background: var(--bg-elev-2); color: var(--fg); font-size: 14px; font-weight: 600; white-space: nowrap; }
.sort-dir svg { width: 16px; height: 16px; }

.seek input { width: 100%; accent-color: var(--accent); height: 28px; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.transport { display: flex; justify-content: space-between; align-items: center; }
.icon-btn.big svg { width: 32px; height: 32px; }
.icon-btn.huge { width: 72px; height: 72px; background: var(--fg); color: var(--bg); }
.icon-btn.huge svg { width: 34px; height: 34px; }
.icon-btn.toggle { color: var(--muted); position: relative; }
.icon-btn.toggle[aria-pressed="true"] { color: var(--accent); }
.repeat-one { position: absolute; font-size: 9px; font-weight: 800; top: 9px; right: 9px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--mini-h) + var(--safe-b) + 18px); z-index: 30; max-width: min(92vw, 520px); padding: 11px 16px; border-radius: 12px; background: var(--fg); color: var(--bg); font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }

/* Phone in landscape: artwork on the left, controls on the right, clear of the notch. */
@media (orientation: landscape) and (max-height: 560px) {
  .player-inner { max-width: 860px; grid-template-columns: auto minmax(0, 1fr); column-gap: 32px; row-gap: 6px; align-items: center; padding-top: calc(4px + var(--safe-t)); padding-bottom: calc(10px + var(--safe-b)); }
  .player-close { grid-row: 1; grid-column: 2; }
  .player-art-wrap { grid-row: 1 / span 2; grid-column: 1; }
  .player-controls { grid-row: 2; grid-column: 2; gap: 12px; }
  .art.large { width: min(calc(100vh - 110px), 42vw, 320px); }
  .lyrics { width: min(46vw, 420px); height: calc(100vh - 60px); padding-block: calc((100vh - 60px) * .42); }
  .player-meta h2 { font-size: 19px; }
}

@media (min-width: 720px) {
  .album-head, .podcast-head { grid-template-columns: 200px 1fr; }
  .podcast-head .art { width: 200px; height: 200px; }
  .album-head .art { width: 200px; height: 200px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* Connection & quality sheet (tap the connection badge or the format line) */
.badge { cursor: pointer; }
.badge:focus-visible, .format-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.format-link { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; margin-top: 2px; border-radius: 999px; }
.format-link:empty { display: none; }
.format-link:active { background: var(--bg-elev-2); }
.quality-tag { font-size: 10px; font-weight: 800; letter-spacing: .05em; padding: 1px 6px; border-radius: 5px; border: 1px solid currentColor; }
.quality-tag.hires { color: var(--warn); }
.quality-tag.lossless { color: var(--ok); }
.info-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; animation: fadein .15s ease-out; }
.info-sheet { width: 100%; max-width: 560px; max-height: min(88vh, 900px); overflow-y: auto; overscroll-behavior: contain; background: var(--bg); border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; padding: 8px 16px calc(18px + var(--safe-b)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .35); animation: slideup .22s ease-out; }
.info-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 8px; }
.info-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.info-head h2 { flex: 1; margin: 0; font-size: 18px; }
.info-hero { display: flex; align-items: center; gap: 14px; }
.info-hero .big { font-size: 17px; font-weight: 700; }
.info-hero .sub { font-size: 13px; color: var(--muted); }
.signal { display: inline-flex; align-items: flex-end; gap: 3px; height: 26px; flex: none; }
.signal i { display: block; width: 6px; border-radius: 2px; background: var(--line); }
.signal i:nth-child(1) { height: 25%; } .signal i:nth-child(2) { height: 50%; } .signal i:nth-child(3) { height: 75%; } .signal i:nth-child(4) { height: 100%; }
.signal[data-level="4"] i, .signal[data-level="3"] i:nth-child(-n+3) { background: var(--ok); }
.signal[data-level="2"] i:nth-child(-n+2) { background: var(--warn); }
.signal[data-level="1"] i:nth-child(1) { background: var(--danger); }
.route { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.route b { padding: 4px 9px; border-radius: 8px; background: var(--bg-elev-2); font-weight: 600; }
.route span { color: var(--muted); }
.route .on { color: var(--ok); }
.meter { height: 6px; border-radius: 3px; background: var(--bg-elev-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); transition: width .4s; }
@keyframes fadein { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .info-backdrop, .info-sheet { animation: none; } }
.info-sheet .kv dd { word-break: normal; overflow-wrap: anywhere; }

/* Sending music (Settings → Enviar música) */
.drop-zone { display: grid; justify-items: center; gap: 8px; padding: 22px 14px; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; font-size: 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.drop-zone svg { width: 30px; height: 30px; }
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); color: var(--fg); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.drop-zone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.upload-list { display: grid; gap: 10px; max-height: 360px; overflow-y: auto; }
.upload-list:empty { display: none; }
.upload-row { display: grid; gap: 4px; min-width: 0; }
.upload-top { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.upload-top .ellipsis { flex: 1; min-width: 0; }
.upload-row.done .meter span { background: var(--ok); }
.upload-row.error .meter span { background: var(--danger); }
.upload-row.error > .tiny { color: var(--danger); }
.upload-recent summary { cursor: pointer; font-size: 14px; }
.upload-recent .kv { margin-top: 8px; max-height: 300px; overflow-y: auto; }
.upload-recent .kv dd { word-break: normal; overflow-wrap: anywhere; }

/* Sharing a song */
.list li.has-action { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.list li.has-action > .row { flex: 1; min-width: 0; border-bottom: 0; }
.share-btn { color: var(--muted); }
.share-btn svg { width: 18px; height: 18px; }
.share-link { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.share-list { display: grid; gap: 10px; margin-top: 10px; }
.share-item { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.share-item .grow { flex: 1; min-width: 0; }
.share-item.ended .ellipsis { color: var(--muted); }
details.card-box > summary { cursor: pointer; font-weight: 700; font-size: 16px; }
.info-hero .art.small { width: 52px; height: 52px; flex: none; }

/* Send menu, playlist picker, playlists */
.sheet-options { display: grid; gap: 4px; }
.sheet-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 8px; border-radius: 12px; text-align: left; min-height: 56px; }
.sheet-option:hover, .sheet-option:focus-visible { background: var(--bg-elev); outline: none; }
.sheet-option:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.sheet-option > svg { width: 22px; height: 22px; flex: none; color: var(--muted); }
.sheet-option > svg:last-child { width: 16px; height: 16px; }
.sheet-option .grow { flex: 1; min-width: 0; display: grid; gap: 2px; }
.sheet-option .title { font-weight: 600; font-size: 15px; }
.sheet-option.new > svg:first-child { color: var(--accent); }
.sheet-option.new .title { color: var(--accent); }
.sheet-track { margin-bottom: 12px; }
.sheet-search { width: 100%; padding: 12px 14px; margin: 4px 0 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg); font-size: 16px; }
.playlist-art.mosaic { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; aspect-ratio: 1; }
.playlist-art.mosaic .art { width: 100% !important; height: auto !important; aspect-ratio: 1; border-radius: 0; box-shadow: none; }
.playlist-art.empty-art { display: grid; place-items: center; color: var(--muted); aspect-ratio: 1; }
.playlist-art.empty-art svg { width: 40%; height: 40%; }
.art.small.playlist-art.empty-art svg { width: 22px; height: 22px; }
.album-head .playlist-art { width: 132px; height: 132px; }
.danger-icon { color: var(--danger); }
.icon-btn:disabled { opacity: .3; }
