/* Tapeclip web player: phone-first, one column. Home lists where music comes from; the player takes the
   whole screen. Same palette as the desktop app: near-black, pink for uncut originals, white primary. */
:root {
  --bg: #0c0b10;
  --bg-raised: #17151d;
  --surface: rgba(255, 255, 255, 0.05);
  --fg: #f4f2f7;
  --muted: #b0aabb;
  --faint: rgba(244, 242, 247, 0.45);
  --line: rgba(255, 255, 255, 0.08);
  --hover: rgba(255, 255, 255, 0.09);
  --pink: #ff5c86;
  --mint: #5fd3a6;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
/* The glow sits on its own layer pinned to the screen: a long page neither repeats it nor shows a seam
   (Safari on iPhone ignores background-attachment: fixed, hence a fixed element). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(600px 380px at 90% -10%, rgba(255, 92, 134, 0.16), transparent 70%),
    radial-gradient(500px 340px at 0% -20%, rgba(167, 139, 250, 0.12), transparent 70%);
  background-repeat: no-repeat;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app {
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.top { display: flex; align-items: center; gap: 10px; height: 44px; font: 700 18px/1 var(--font-display); }
.top .logo { width: 30px; height: 30px; }

/* ---------- home ---------- */
.home { padding-top: 24px; display: grid; gap: 12px; align-content: start; }
.home h1 { margin: 0; font: 700 30px/1.15 var(--font-display); letter-spacing: -0.02em; }
.lede { margin: 0 0 12px; color: var(--muted); }
.source {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
}
.source:active:not(.disabled) { background: var(--hover); }
.source.disabled { opacity: 0.5; }
.source-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--hover); color: var(--muted); }
.source-icon.pink { background: rgba(255, 92, 134, 0.16); color: var(--pink); }
.source-icon svg { width: 22px; height: 22px; }
.source-text { display: grid; gap: 2px; min-width: 0; }
.source-text small { color: var(--muted); font-size: 13px; }
.chev { color: var(--faint); font-size: 26px; line-height: 1; }
.sources { display: grid; gap: 12px; }
.link-btn { justify-self: center; height: 36px; padding: 0 12px; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.login-card { display: grid; gap: 12px; padding: 18px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); text-align: center; }
.login-card p { margin: 0; color: var(--muted); }
.login-card a { color: var(--fg); font-weight: 600; }
.code { font: 700 34px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.12em; color: var(--fg); user-select: all; -webkit-user-select: all; }

/* ---------- player ---------- */
.player { display: none; flex: 1; flex-direction: column; gap: 18px; padding-top: 8px; will-change: transform; }
.app[data-screen="player"] .player { display: flex; }
.app:not([data-screen="home"]) .home { display: none; }
.back { align-self: flex-start; width: 40px; height: 40px; margin-left: -8px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.back svg { width: 24px; height: 24px; }
.cover {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  background:
    url("icon-512.png") center / 46% no-repeat,
    linear-gradient(145deg, #2a1830, #121019 60%);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover img:not([src]), .cover img[src=""] { display: none; }
.meta { display: grid; gap: 4px; min-width: 0; }
.title-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.title-text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.meta h2 { margin: 0; font: 700 24px/1.2 var(--font-display); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta p { margin: 0; color: var(--muted); font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { justify-self: start; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255, 92, 134, 0.15); color: var(--pink); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.catalog { background: rgba(95, 211, 166, 0.13); color: var(--mint); }
.badge.searching { background: var(--hover); color: var(--muted); }
.badge.searching::before { width: 9px; height: 9px; background: none; border: 1.6px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .badge.searching::before { animation-duration: 2.4s; } }

.progress input { width: 100%; margin: 0; accent-color: var(--fg); height: 24px; }
.times { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; justify-content: center; gap: 18px; }
.ctl { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; }
.ctl svg { width: 30px; height: 30px; fill: currentColor; stroke-width: 1.4; }
.ctl:active { background: var(--hover); }
.ctl.play { width: 76px; height: 76px; background: var(--fg); color: var(--bg); }
.ctl.play svg { width: 34px; height: 34px; }
.ctl.play:active { background: #fff; }
.ctl .i-pause, .app.playing .ctl .i-play { display: none; }
.app.playing .ctl .i-pause { display: block; }

.flag { align-self: center; height: 40px; padding: 0 16px; border-radius: 999px; background: var(--hover); font-size: 14px; font-weight: 600; }
.hint { margin: 0; text-align: center; color: var(--faint); font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(30, 28, 37, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-size: 14px;
}

@media (min-height: 860px) { .player { gap: 24px; } }
@media (max-height: 700px) { .cover { width: 78%; align-self: center; } }

/* ---------- player actions ---------- */
.act { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.act svg { width: 24px; height: 24px; }
.act:active { background: var(--hover); }
.act.on { color: var(--pink); }
#btn-like.on svg { fill: currentColor; }
.act.small svg { width: 21px; height: 21px; }
.controls .act[hidden] { display: grid !important; visibility: hidden; } /* keeps the play button centered */
.fix { display: flex; justify-content: center; align-items: center; gap: 6px; color: var(--faint); }

/* ---------- browse ---------- */
.browse { display: none; flex-direction: column; gap: 10px; padding-top: 8px; }
.app[data-screen="browse"] .browse { display: flex; }
.browse-head { display: flex; align-items: center; gap: 4px; min-width: 0; }
.browse-head h2 { margin: 0; font: 700 24px/1.2 var(--font-display); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browse-head .back { margin: 0 0 0 -8px; }
.search input { width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3); color: var(--fg); font: inherit; }
.search input:focus { outline: 2px solid var(--pink); outline-offset: 0; }
.rows { display: grid; gap: 2px; }
.row { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: center; width: 100%; padding: 6px 4px; border-radius: 10px; text-align: left; }
.row:active { background: var(--hover); }
.row.now { background: rgba(255, 92, 134, 0.1); }
.row-img { width: 48px; height: 48px; border-radius: 8px; overflow: hidden; background: var(--hover); }
.row-img.round { border-radius: 50%; }
.row-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-text { display: grid; min-width: 0; }
.row-text b, .row-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-text b { font-weight: 600; }
.row-text small { color: var(--muted); font-size: 13px; }
.section { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 600; }
.list-actions { display: flex; gap: 10px; margin: 2px 0 8px; }
.pill { height: 40px; padding: 0 20px; border-radius: 999px; background: var(--hover); font-weight: 600; }
.pill.primary { background: var(--fg); color: var(--bg); }
.pill.wide { width: 100%; height: 48px; }
.resume { border-color: rgba(255, 92, 134, 0.3); }
#how-it-works { margin-top: 4px; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0.55); }
.sheet-panel { width: 100%; max-width: 520px; max-height: 82vh; overflow-y: auto; padding: 18px 16px max(20px, env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: var(--bg-raised); border-top: 1px solid var(--line); }
.sheet-panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-panel h3 { margin: 0; font: 600 17px/1.3 var(--font-display); }
.onboard h2 { margin: 4px 0 14px; font: 700 24px/1.2 var(--font-display); }
.onboard ol { margin: 0 0 18px; padding-left: 22px; display: grid; gap: 12px; color: var(--muted); }
.onboard li b { color: var(--fg); }

/* ---------- mini player ---------- */
.mini {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 5;
  width: calc(min(520px, 100%) - 20px);
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 12px;
  align-items: center;
  padding: 8px 8px 8px 8px;
  border-radius: 14px;
  background: rgba(30, 28, 37, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.mini-img { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: url("icon-180.png") center / 70% no-repeat, var(--hover); }
.mini-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-img img:not([src]) { display: none; }
.mini-text { display: grid; min-width: 0; }
.mini-text b, .mini-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-text b { font-weight: 600; font-size: 15px; }
.mini-text small { color: var(--muted); font-size: 13px; }
.mini-play { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.mini-play svg { width: 24px; height: 24px; fill: currentColor; stroke-width: 1.4; }
.mini-play:active { background: var(--hover); }
.mini .i-pause, .app.playing .mini .i-play { display: none; }
.app.playing .mini .i-pause { display: block; }
.app.has-mini .home, .app.has-mini .browse { padding-bottom: 84px; }
.app.has-mini .toast { bottom: calc(max(24px, env(safe-area-inset-bottom)) + 70px); }

/* ---------- song tags: uncut or from Yandex ---------- */
.row.tagged { grid-template-columns: 48px minmax(0, 1fr) auto; }
.tag { justify-self: end; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 22px; white-space: nowrap; }
.tag.uncut { background: rgba(255, 92, 134, 0.15); color: var(--pink); }
.tag.catalog { background: rgba(95, 211, 166, 0.12); color: var(--mint); }
.tag.pending { color: var(--faint); }
.pill.wide-ghost { width: 100%; margin-top: 10px; background: var(--surface); border: 1px solid var(--line); }

/* ---------- problem reports ---------- */
.foot-links { display: flex; justify-content: center; align-items: center; gap: 4px; margin-top: 4px; }
.foot-links .link-btn { margin: 0; }
#report-player { align-self: center; font-size: 13px; }
#feedback-text { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3); color: var(--fg); font: inherit; resize: vertical; }
#feedback-text:focus { outline: 2px solid var(--pink); outline-offset: 0; }

/* ---------- language switch ---------- */
.lang-switch { margin-left: auto; display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.lang-switch button { height: 28px; min-width: 38px; padding: 0 10px; border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 600; }
.lang-switch button.on { background: var(--fg); color: var(--bg); }

/* ---------- motion: soft, iOS-like ---------- */
:root { --ease-out: cubic-bezier(0.22, 1, 0.36, 1); }
.app[data-screen="player"] .player { animation: rise 0.42s var(--ease-out); }
.app[data-screen="browse"] .browse { animation: slide-in 0.34s var(--ease-out); }
.app[data-screen="home"] .home { animation: fade-in 0.3s ease; }
.mini { animation: mini-in 0.4s var(--ease-out); }
.sheet { animation: fade-in 0.25s ease; }
.sheet .sheet-panel { animation: sheet-up 0.42s var(--ease-out); }
.toast { animation: toast-in 0.3s var(--ease-out); }
.source, .row, .pill, .ctl, .act, .mini-play, .flag, .lang-switch button { transition: transform 0.18s var(--ease-out), background-color 0.2s ease, opacity 0.2s ease; }
.source:active, .row:active, .pill:active, .flag:active { transform: scale(0.98); }
.ctl:active, .act:active, .mini-play:active { transform: scale(0.92); }
.badge, .tag { transition: background-color 0.3s ease, color 0.3s ease; }
.cover img { transition: opacity 0.35s ease; }

@keyframes rise { from { transform: translateY(48px); opacity: 0; } }
@keyframes slide-in { from { transform: translateX(28px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes mini-in { from { transform: translate(-50%, 24px); opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes toast-in { from { transform: translate(-50%, 12px); opacity: 0; } }

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