/* ============================================================
   Imaning app — mobile-first music player skin
   Uses the site's brand tokens (violet → cyan on near-black)
   ============================================================ */

:root {
  --bg: #0b0b12;
  --surface: #14141f;
  --surface-2: #1c1c2b;
  --surface-3: #24243a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f2f2f7;
  --muted: #9a9ab0;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --gradient: linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
  --danger: #f43f5e;
  --success: #34d399;
  --radius: 16px;
  --tab-h: 62px;
  --mini-h: 62px;
  --top-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 80% -8%, rgba(139, 92, 246, 0.20), transparent 60%),
    radial-gradient(700px 380px at 5% 6%, rgba(34, 211, 238, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
}

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
img { display: block; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
[hidden] { display: none !important; }

/* ---------------- top bar ---------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, rgba(11, 11, 18, 0.96), rgba(11, 11, 18, 0.72) 70%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.02em; font-size: 1.05rem; }
.brand img { border-radius: 7px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.pill {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 8px 14px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
}
.pill.sm { padding: 7px 12px; font-size: 0.75rem; }
.pill.primary { background: var(--gradient); border-color: transparent; color: #08101a; font-weight: 700; }
.pill:active { transform: scale(0.96); }

.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 50%; color: var(--text); opacity: 0.92;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { background: rgba(255, 255, 255, 0.08); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 1.15rem; color: var(--muted); }
.icon-btn.like.on { color: var(--accent-2); }
.icon-btn.like.on svg { fill: var(--accent-2); stroke: var(--accent-2); }
.icon-btn.on { color: var(--accent-2); }

.offline-bar {
  position: fixed; top: calc(var(--top-h) + env(safe-area-inset-top)); left: 0; right: 0;
  z-index: 45; padding: 6px 12px; text-align: center; font-size: 0.75rem;
  background: rgba(251, 191, 36, 0.16); color: #fde68a; border-bottom: 1px solid rgba(251, 191, 36, 0.25);
}

/* ---------------- scroll views ---------------- */
.views {
  position: absolute; inset: 0;
  padding-top: calc(var(--top-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--tab-h) + var(--mini-h) + env(safe-area-inset-bottom) + 8px);
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.views::-webkit-scrollbar { display: none; }
.view { padding: 8px 16px 32px; animation: fade 0.22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.greeting { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; margin: 6px 0 2px; }
.sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 16px; }
.muted { color: var(--muted); font-size: 0.76rem; font-weight: 500; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 10px; }
.section-head h2 { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.02em; }
.link { color: var(--accent-2); font-size: 0.76rem; font-weight: 600; padding: 4px; }

/* ---------------- quick tiles (home) ---------------- */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.06); border-radius: 10px;
  overflow: hidden; height: 56px; padding-right: 10px;
  border: 1px solid transparent;
}
.quick img { width: 56px; height: 56px; object-fit: cover; }
.quick span { font-size: 0.8rem; font-weight: 600; line-height: 1.2; }
.quick:active { background: rgba(255, 255, 255, 0.11); }

/* ---------------- horizontal cards ---------------- */
.hscroll {
  display: flex; gap: 12px; overflow-x: auto; padding: 2px 16px 6px;
  margin: 0 -16px; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.hscroll::-webkit-scrollbar { display: none; }
.hcard { flex: 0 0 138px; scroll-snap-align: start; }
.hcard .art { width: 138px; height: 138px; border-radius: 12px; overflow: hidden; background: var(--surface-2); position: relative; }
.hcard .art img { width: 100%; height: 100%; object-fit: cover; }
.hcard .t { font-size: 0.84rem; font-weight: 600; margin-top: 8px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.hcard .s { font-size: 0.74rem; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------------- track rows ---------------- */
.track {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  padding: 7px 4px; border-radius: 10px;
}
.track.with-rank { grid-template-columns: 20px 44px 1fr auto; gap: 10px; }
.track.with-rank .cover { width: 44px; height: 44px; }
.track.with-rank .rank { align-self: center; }
.track:active { background: rgba(255, 255, 255, 0.07); }
.track .cover { width: 48px; height: 48px; border-radius: 8px; overflow: hidden; background: var(--surface-2); position: relative; }
.track .cover img { width: 100%; height: 100%; object-fit: cover; }
.track .meta { min-width: 0; }
.track .t { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .s { font-size: 0.76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.track .end { display: flex; align-items: center; gap: 2px; }
.track .rank { font-size: 0.95rem; font-weight: 700; color: var(--muted); text-align: center; }
.track.playing .t { color: var(--accent-2); }
.track.playing .cover::after {
  content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5);
}
.bars { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 2px; z-index: 2; }
.bars i { width: 3px; height: 30%; background: var(--accent-2); border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: 0.15s; height: 55%; }
.bars i:nth-child(3) { animation-delay: 0.3s; height: 40%; }
@keyframes eq { 0%, 100% { transform: scaleY(0.45); } 50% { transform: scaleY(1); } }
body.paused .bars i { animation-play-state: paused; }

/* ---------------- playlists ---------------- */
.playlist-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pl-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.pl-card:active { background: var(--surface-2); }
.pl-art { height: 104px; border-radius: 10px; display: grid; place-items: center; font-size: 1.9rem; margin-bottom: 9px; color: #0a0a12; font-weight: 800; }
.pl-card b { font-size: 0.84rem; display: block; }
.pl-card span { font-size: 0.72rem; color: var(--muted); }

/* ---------------- search ---------------- */
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 12px; height: 46px; margin: 6px 0 12px;
}
.search-box svg { width: 19px; height: 19px; color: var(--muted); flex: none; }
.search-box input { flex: 1; background: none; border: 0; outline: none; color: var(--text); font-size: 0.95rem; min-width: 0; }
.search-box input::placeholder { color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin-bottom: 6px; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn {
  flex: none; padding: 7px 14px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  background: rgba(255, 255, 255, 0.07); color: var(--muted); border: 1px solid transparent;
}
.chip-btn.active { background: var(--gradient); color: #08101a; }
.recents { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

.empty { text-align: center; color: var(--muted); font-size: 0.86rem; padding: 40px 20px; line-height: 1.5; }
.empty svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: 0.5; }

/* ---------------- library ---------------- */
.segmented { display: flex; gap: 6px; background: var(--surface); padding: 4px; border-radius: 12px; margin: 8px 0 16px; }
.segmented button { flex: 1; padding: 9px; border-radius: 9px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.segmented button.active { background: var(--surface-3); color: var(--text); }

/* ---------------- downloads / stats ---------------- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 10px; text-align: center; }
.stat b { display: block; font-size: 1.2rem; letter-spacing: -0.02em; }
.stat span { font-size: 0.7rem; color: var(--muted); }

.install-card {
  display: flex; align-items: center; gap: 12px; margin-top: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
}
.install-card img { border-radius: 10px; }
.install-card b { font-size: 0.88rem; }
.install-card p { font-size: 0.76rem; color: var(--muted); line-height: 1.45; margin-top: 3px; }
.install-card .btn { margin-left: auto; flex: none; }
.btn { background: var(--gradient); color: #08101a; font-weight: 700; font-size: 0.8rem; padding: 9px 15px; border-radius: 999px; }

/* ---------------- mini player ---------------- */
.mini {
  position: fixed; left: 8px; right: 8px; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 6px);
  height: var(--mini-h); z-index: 38;
  display: flex; align-items: center; gap: 10px; padding: 0 8px 0 6px;
  background: rgba(30, 30, 46, 0.94); backdrop-filter: blur(18px);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  animation: miniIn 0.24s ease;
  overflow: hidden;
}
@keyframes miniIn { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.mini img { border-radius: 9px; object-fit: cover; flex: none; }
.mini-meta { flex: 1; min-width: 0; }
.mini-meta #mini-title { font-size: 0.83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-meta #mini-artist { font-size: 0.73rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-progress { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: rgba(255, 255, 255, 0.08); }
.mini-progress i { display: block; height: 100%; width: 0; background: var(--gradient); transition: width 0.25s linear; }
.mini .icon-btn svg { width: 24px; height: 24px; }
.mini-spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid rgba(255, 255, 255, 0.18); border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- tab bar ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 39;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(11, 11, 18, 0.96); backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); }
.tab svg { width: 21px; height: 21px; }
.tab span { font-size: 0.64rem; font-weight: 600; letter-spacing: 0.01em; }
.tab.active { color: var(--text); }
.tab.active svg { color: var(--accent-2); }

/* ---------------- sheets ---------------- */
.backdrop { position: fixed; inset: 0; z-index: 48; background: rgba(0, 0, 0, 0.55); animation: fade 0.2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #171723, #101018);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  animation: sheetUp 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  scrollbar-width: none;
}
.sheet::-webkit-scrollbar { display: none; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grab { width: 38px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.22); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { font-size: 1rem; font-weight: 700; }
.sheet-head-actions { display: flex; gap: 2px; }
.sheet-body { padding-bottom: 10px; }

/* ---------------- full player ---------------- */
.player-sheet { height: 100%; max-height: none; border-radius: 0; display: flex; flex-direction: column; justify-content: space-between; }
.np-head { display: flex; align-items: center; justify-content: space-between; }
.np-context { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; }
.np-art-wrap { position: relative; margin: 10px auto 0; width: min(78vw, 340px); aspect-ratio: 1; }
.np-art {
  width: 100%; height: 100%; object-fit: cover; border-radius: 18px;
  background: var(--surface-2); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.np-buffering {
  position: absolute; inset: 0; border-radius: 18px; display: grid; place-items: center;
  background: rgba(8, 8, 14, 0.55);
}
.np-buffering::after {
  content: ''; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2); border-top-color: var(--accent-2);
  animation: spin 0.85s linear infinite;
}
.np-info { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.np-text { flex: 1; min-width: 0; }
.np-text h2 { font-size: 1.28rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-text p { font-size: 0.86rem; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-side { display: flex; gap: 4px; }

.seek-wrap { margin-top: 16px; }
.seek-wrap input, .seek {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 5px; border-radius: 4px; outline: none;
  background: rgba(255, 255, 255, 0.14);
}
.seek-wrap input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
}
.times { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); margin-top: 7px; font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.controls .icon-btn.big svg { width: 27px; height: 27px; }
.play-btn {
  width: 62px; height: 62px; border-radius: 50%; background: var(--gradient);
  display: grid; place-items: center; color: #0a0a12;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35);
}
.play-btn svg { width: 26px; height: 26px; }
.play-btn:active { transform: scale(0.94); }

.np-extra { display: flex; gap: 8px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* ---------------- menu ---------------- */
.menu {
  position: fixed; z-index: 60; min-width: 208px;
  background: #1e1e2c; border: 1px solid var(--line); border-radius: 13px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6); padding: 6px;
  animation: fade 0.14s ease;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 12px; border-radius: 9px; font-size: 0.84rem; text-align: left; font-weight: 500;
}
.menu button:active { background: rgba(255, 255, 255, 0.08); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

/* ---------------- queue ---------------- */
.q-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 8px; font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.q-item { display: grid; grid-template-columns: 20px 42px 1fr auto; gap: 10px; align-items: center; padding: 7px 2px; border-radius: 9px; }
.q-item img { width: 42px; height: 42px; border-radius: 7px; object-fit: cover; }
.q-item .grip { color: var(--muted); font-size: 0.9rem; text-align: center; }
.q-item .t { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-item .s { font-size: 0.72rem; color: var(--muted); }

/* ---------------- settings ---------------- */
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 2px; border-bottom: 1px solid var(--line); font-size: 0.87rem; }
.about { color: var(--muted); font-size: 0.76rem; line-height: 1.55; margin-top: 16px; }

/* ---------------- toasts ---------------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--mini-h) + 22px + env(safe-area-inset-bottom)); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: #26263a; color: var(--text); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; font-size: 0.8rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); animation: toastIn 0.2s ease; }
.toast.ok { border-color: rgba(52, 211, 153, 0.4); }
.toast.err { border-color: rgba(244, 63, 94, 0.45); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------- tablet / desktop ---------------- */
@media (min-width: 700px) {
  .views { max-width: 860px; margin: 0 auto; }
  .topbar { max-width: 860px; margin: 0 auto; left: 50%; transform: translateX(-50%); width: 100%; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .hcard { flex-basis: 168px; }
  .hcard .art { width: 168px; height: 168px; }
  .playlist-grid { grid-template-columns: repeat(3, 1fr); }
  .player-sheet { max-height: 640px; border-radius: 22px 22px 0 0; }
  .np-art-wrap { width: min(46vw, 320px); }
  .tabbar { max-width: 560px; margin: 0 auto; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
}

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