/* Ghost Music — Mini App */
:root, :root[data-theme="dark"] {
  --bg: #0B0B10; --surface: #16161E; --surface2: #1E1E28; --line: #2A2A36; --line2: #22222C;
  --text: #F2F1F7; --muted: #9A99A8; --accent: #A7F3D0; --accent-ink: #0B0B10; --accent-text: #A7F3D0;
  --wave-bg: #16161E; --wave-text: #F2F1F7; --wave-muted: #9A99A8; --danger: #FCA5A5; --danger-line: #4A2A30;
  --t1b: #2B2140; --t1f: #E9D5FF; --t2b: #1C2A33; --t2f: #BAE6FD; --t3b: #1A2E27; --t3f: #A7F3D0;
  --t4b: #33261A; --t4f: #FED7AA; --t5b: #331A26; --t5f: #FBCFE8;
  --seg: #0B0B10; --seg-on: #F2F1F7; --seg-on-text: #0B0B10; --invert: #F2F1F7; --invert-text: #0B0B10;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F6F6F9; --surface: #FFFFFF; --surface2: #FFFFFF; --line: #E4E4EC; --line2: #EDEDF2;
  --text: #15151C; --muted: #5E5D6B; --accent: #A7F3D0; --accent-ink: #0B0B10; --accent-text: #0F766E;
  --wave-bg: #15151C; --wave-text: #F2F1F7; --wave-muted: #B4B3C0; --danger: #B91C1C; --danger-line: #F5C2C2;
  --t1b: #EDE4FB; --t1f: #5B21B6; --t2b: #E0F2FE; --t2f: #075985; --t3b: #D1FAE5; --t3f: #065F46;
  --t4b: #FFEDD5; --t4f: #9A3412; --t5b: #FCE7F3; --t5f: #9D174D;
  --seg: #EDEDF2; --seg-on: #15151C; --seg-on-text: #F6F6F9; --invert: #15151C; --invert-text: #F6F6F9;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: Manrope, system-ui, sans-serif; font-size: 15px; min-height: 100vh; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
.hidden { display: none !important; }
.display { font-family: Unbounded, sans-serif; font-weight: 700; letter-spacing: -0.03em; }
.caps { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

#view { max-width: 560px; margin: 0 auto; padding: 20px 16px 190px; display: flex; flex-direction: column; gap: 26px; }

/* шапка */
.top { display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 10px; font-family: Unbounded, sans-serif; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.logo .m { font-weight: 500; color: var(--muted); }
.round { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.round.big { width: 48px; height: 48px; border: none; }
.round[aria-pressed="true"] { color: var(--accent-text); }
.hello { display: flex; flex-direction: column; gap: 6px; }
.hello h1, .page-title { margin: 0; font-size: 30px; line-height: 1.1; }

/* волна */
.wave { position: relative; overflow: hidden; border-radius: 28px; background: var(--wave-bg); color: var(--wave-text); border: 1px solid var(--line); padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.wave::before { content: ""; position: absolute; right: -30px; top: -30px; width: 170px; height: 170px; border-radius: 50%; background: var(--accent); opacity: .1; }
.wave::after { content: ""; position: absolute; right: 18px; top: 18px; width: 90px; height: 90px; border-radius: 50%; border: 1px dashed var(--accent); opacity: .4; animation: drift 9s ease-in-out infinite; }
@keyframes drift { 50% { transform: translate(-10px, 8px) scale(1.06); } }
.wave .caps { color: var(--accent); }
.wave h2 { margin: 0 0 4px; font-size: 22px; }
.wave p { margin: 0; color: var(--wave-muted); font-size: 14px; }
.wave-row { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.btn-play { width: 56px; height: 56px; border-radius: 28px; border: none; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; padding: 0; }

/* плитки */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line2); color: var(--text); text-decoration: none; text-align: left; min-height: 64px; }
.tile .ic { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tile b { display: block; font-size: 14px; }
.tile small { font-size: 12px; color: var(--muted); }
.c1 { background: var(--t1b); color: var(--t1f); } .c2 { background: var(--t2b); color: var(--t2f); }
.c3 { background: var(--t3b); color: var(--t3f); } .c4 { background: var(--t4b); color: var(--t4f); }
.c5 { background: var(--t5b); color: var(--t5f); }

/* секции */
.sec { display: flex; flex-direction: column; gap: 12px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sec-head h2 { margin: 0; font-size: 18px; }
.sec-head a, .link-btn { font-size: 14px; font-weight: 700; text-decoration: none; padding: 12px 0; background: none; border: none; color: var(--accent-text); }
.row-scroll { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.row-scroll::-webkit-scrollbar { display: none; }
.pl-card { width: 140px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; color: var(--text); text-decoration: none; background: none; border: none; padding: 0; text-align: left; }
.pl-art { width: 140px; height: 140px; border-radius: 20px; display: flex; align-items: flex-end; padding: 14px; overflow: hidden; background-size: cover; background-position: center; font-family: Unbounded, sans-serif; font-weight: 700; font-size: 18px; word-break: break-word; }
.pl-new { border: 1.5px dashed var(--line); justify-content: center; align-items: center; color: var(--muted); }
.pl-card b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-card small { font-size: 12px; color: var(--muted); margin-top: -6px; }
.pl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.pl-grid .pl-card, .pl-grid .pl-art { width: 100%; }
.pl-grid .pl-art { height: auto; aspect-ratio: 1; }

/* поиск */
.search-box { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 8px 0 18px; border-radius: 28px; background: var(--invert); color: var(--invert-text); }
.search-box input { flex: 1; min-width: 0; border: none; background: transparent; font-size: 16px; outline: none; color: var(--invert-text); }
.search-box input::placeholder { color: var(--invert-text); opacity: .55; }
.search-box .clear { width: 40px; height: 40px; border: none; background: none; color: var(--invert-text); display: flex; align-items: center; justify-content: center; }
.link-card { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 16px; border-radius: 20px; border: 1px dashed var(--line); background: var(--surface); text-align: left; margin-top: -12px; }
.link-card .ic { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; }
.moods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mood { position: relative; overflow: hidden; height: 92px; border-radius: 20px; border: none; padding: 16px; text-align: left; font-family: Unbounded, sans-serif; font-weight: 700; font-size: 16px; display: flex; align-items: flex-start; }
.mood::after { content: ""; position: absolute; right: -18px; bottom: -18px; width: 72px; height: 72px; border-radius: 50%; border: 2px solid currentColor; opacity: .35; }

/* список треков */
.tracks { display: flex; flex-direction: column; }
.trk { display: flex; align-items: center; gap: 12px; padding: 6px 0; min-height: 60px; }
.trk-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; background: none; border: none; padding: 0; text-align: left; }
.trk-cover { position: relative; width: 52px; height: 52px; border-radius: 12px; background: var(--surface) center/cover; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.trk.on .trk-cover::after { content: ""; position: absolute; inset: 0; border-radius: 12px; box-shadow: inset 0 0 0 2px var(--accent); }
.trk-txt { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trk-txt b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trk.on .trk-txt b { color: var(--accent-text); }
.trk-txt span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 2px 6px; border-radius: 6px; background: var(--surface2); color: var(--muted); border: 1px solid var(--line); vertical-align: 1px; }
.badge:empty { display: none; }
.icon-btn { width: 44px; height: 44px; border: none; background: none; display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; padding: 0; }
.icon-btn[aria-pressed="true"] { color: var(--accent-text); }
.empty { padding: 28px 20px; border-radius: 24px; background: var(--surface); text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.empty p { margin: 0; }
.btn { min-height: 48px; padding: 0 22px; border-radius: 24px; border: none; background: var(--invert); color: var(--invert-text); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--danger); border: 1px solid var(--danger-line); width: 100%; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; min-height: 44px; }
.loader { display: flex; justify-content: center; padding: 30px; color: var(--muted); }
.loader svg { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); opacity: .6; } }

/* настройки */
.group { display: flex; flex-direction: column; gap: 8px; }
.group > .caps { margin-left: 4px; }
.card { border-radius: 20px; background: var(--surface); overflow: hidden; }
.item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 10px 16px; border: none; background: none; text-align: left; text-decoration: none; color: var(--text); font-weight: 500; border-bottom: 1px solid var(--line2); }
.item:last-child { border-bottom: none; }
.item .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.item small { font-size: 12px; color: var(--muted); font-weight: 400; }
.theme-block { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line2); }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 16px; background: var(--seg); }
.seg button { height: 44px; border-radius: 12px; border: none; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.seg button[aria-checked="true"] { background: var(--seg-on); color: var(--seg-on-text); }
.profile { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line2); }
.avatar { width: 56px; height: 56px; border-radius: 28px; display: flex; align-items: center; justify-content: center; font-family: Unbounded, sans-serif; font-weight: 700; font-size: 20px; flex-shrink: 0; }

/* мини-плеер */
.mini { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); width: calc(100% - 24px); max-width: 536px; display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 20px; background: var(--surface2); border: 1px solid var(--line); z-index: 20; overflow: hidden; }
.mini-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; background: none; border: none; padding: 0; text-align: left; }
.mini-cover { width: 44px; height: 44px; border-radius: 12px; background: var(--t3b) center/cover; flex-shrink: 0; }
.mini-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mini-title { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-artist { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-play { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--invert); color: var(--invert-text); display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0; }
.mini-progress { position: absolute; left: 16px; right: 16px; bottom: 0; height: 2px; background: var(--line); }
.mini-progress span { display: block; height: 2px; width: 0; background: var(--accent); }

/* меню */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 8px 12px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line2); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 52px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; }
.tabs a::after { content: ""; width: 4px; height: 4px; border-radius: 2px; }
.tabs a[aria-current="page"] { color: var(--accent-text); font-weight: 700; }
.tabs a[aria-current="page"]::after { background: var(--accent-text); }

/* плеер */
.player { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; gap: 22px; padding: 16px 24px calc(24px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; transform: translateY(105%); transition: transform .32s cubic-bezier(.2,.8,.2,1); overflow-y: auto; }
.player.open { transform: none; }
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.player-head .round { border: none; }
.player-from { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; font-size: 14px; font-weight: 700; text-align: center; }
.player-cover { position: relative; width: 100%; aspect-ratio: 1 / .9; max-height: 46vh; border-radius: 32px; background: var(--t3b); overflow: hidden; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.player-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.player-cover img:not([src]), .player-cover img[src=""] { display: none; }
.ghost-art { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--t3f); }
.ghost-art::before, .ghost-art::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid currentColor; }
.ghost-art::before { width: 76%; aspect-ratio: 1; opacity: .18; }
.ghost-art::after { width: 52%; aspect-ratio: 1; opacity: .3; }
.yt-box { position: absolute; inset: 0; background: #000; display: none; }
.yt-box.on { display: block; }
.yt-box iframe, .yt-box > div { width: 100%; height: 100%; border: 0; }
.player-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.player-titles { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.player-titles h1 { margin: 0; font-family: Unbounded, sans-serif; font-weight: 700; font-size: 22px; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-titles span { font-size: 16px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seek { display: flex; flex-direction: column; gap: 6px; }
.full-btn { display: block; margin: 10px auto 0; min-height: 36px; padding: 0 16px; border-radius: 18px; border: none; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; }
.full-btn.hidden { display: none; }
.times {display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; margin: 0; --p: 0%; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(var(--accent), var(--accent)) 0 / var(--p) 100% no-repeat, var(--line); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%; background: var(--text); border: none; }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: none; }
.controls { display: flex; align-items: center; justify-content: space-between; }
.ctl { width: 44px; height: 44px; border: none; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.ctl.lg { width: 56px; height: 56px; color: var(--text); }
.ctl.play { width: 80px; height: 80px; border-radius: 40px; background: var(--accent); color: var(--accent-ink); }
.ctl[aria-pressed="true"] { color: var(--accent-text); }
.volume { display: flex; align-items: center; gap: 8px; }
.player-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: auto; }
.chip-btn { min-height: 48px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 6px; }

/* листы и тосты */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 105%); width: 100%; max-width: 560px; max-height: 80vh; overflow-y: auto; z-index: 51; background: var(--surface2); border-radius: 28px 28px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); transition: transform .28s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; gap: 12px; }
.sheet.open { transform: translate(-50%, 0); }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 6px; }
.sheet h3 { margin: 0; font-size: 18px; }
.field { width: 100%; height: 52px; padding: 0 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; outline: none; }
.field:focus { border-color: var(--accent-text); }
.toast { position: fixed; left: 50%; top: 16px; transform: translate(-50%, -150%); z-index: 60; background: var(--invert); color: var(--invert-text); padding: 12px 18px; border-radius: 16px; font-size: 14px; font-weight: 700; transition: transform .25s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
