/* music.shayanisaac.cc - a small Spotify-style shell around Spotify's official player. */
:root {
  --bg: #000;
  --panel: #121212;
  --card: #181818;
  --card-hover: #282828;
  --line: #2a2a2a;
  --text: #fff;
  --muted: #b3b3b3;
  --accent: #1ed760;
  --accent-dark: #169c46;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.4 "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
svg { fill: currentColor; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  height: 100dvh;
  padding: 8px;
}
.side { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.panel { background: var(--panel); border-radius: var(--radius); }

/* ---------- nav ---------- */

.nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 12px 12px;
  font-weight: 800; font-size: 19px; letter-spacing: -0.01em;
  text-decoration: none;
}
.brand svg { width: 32px; height: 32px; flex: none; }
.nav-item {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 12px;
  background: none; border: 0; border-radius: 6px;
  color: var(--muted); font-weight: 700; font-size: 16px;
  text-decoration: none; text-align: left; cursor: pointer;
  transition: color 0.15s;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item:hover, .nav-item.on { color: var(--text); }

/* ---------- library ---------- */

.lib { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 8px; }
.lib-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px 10px; }
.lib-head h2 { margin: 0; font-size: 16px; color: var(--muted); }
.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  background: none; border: 0; border-radius: 50%;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--card-hover); }
.icon-btn svg { width: 20px; height: 20px; }

.lib-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.lib-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px; background: none; border: 0; border-radius: 6px;
  text-align: left; cursor: pointer;
}
.lib-item:hover { background: var(--card); }
.lib-item.on { background: var(--card-hover); }
.lib-item img, .lib-item .ph {
  width: 48px; height: 48px; flex: none;
  border-radius: 4px; object-fit: cover; background: var(--card-hover);
}
.lib-item.artist img { border-radius: 50%; }
.lib-item span { min-width: 0; }
.lib-item b, .lib-item small {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.lib-item b { font-weight: 600; }
.lib-item.on b { color: var(--accent); }
.lib-item small { color: var(--muted); font-size: 13px; text-transform: capitalize; }

/* ---------- main ---------- */

.main {
  position: relative; overflow-y: auto; min-height: 0;
  background: linear-gradient(180deg, var(--hue, #1f3a2a) 0, var(--panel) 320px);
}
.view { padding: 24px; }
.main h1 { margin: 8px 0 20px; font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.card {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; background: var(--card);
  border: 0; border-radius: var(--radius);
  text-align: left; cursor: pointer;
  transition: background 0.2s;
}
.card:hover, .card:focus-visible { background: var(--card-hover); outline: none; }
.card img, .card .ph {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 6px; background: var(--card-hover);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.card.artist img { border-radius: 50%; }
.card b {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-weight: 700;
}
.card small { color: var(--muted); text-transform: capitalize; }
.card .play {
  position: absolute; right: 20px; top: calc(100% - 118px);
  display: grid; place-items: center;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: #000;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.card .play svg { width: 22px; height: 22px; }
.card:hover .play, .card:focus-visible .play { opacity: 1; transform: none; }

.hint { margin: 28px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- player view ---------- */

.hero { display: flex; align-items: flex-end; gap: 24px; margin-bottom: 20px; }
.hero-art {
  width: 180px; height: 180px; flex: none;
  border-radius: 6px; object-fit: cover; background: var(--card-hover);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
}
.hero-art.artist { border-radius: 50%; }
.hero-text { min-width: 0; }
.hero-type { font-size: 13px; font-weight: 700; text-transform: capitalize; }
.hero h1 {
  margin: 6px 0 16px; font-size: clamp(26px, 4.5vw, 56px); line-height: 1.05;
  overflow-wrap: anywhere;
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border: 0; border-radius: 999px;
  background: var(--accent); color: #000;
  font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.pill:hover { transform: scale(1.04); }
.pill.ghost { background: none; color: var(--text); box-shadow: inset 0 0 0 1px #727272; }
.pill.ghost:hover { box-shadow: inset 0 0 0 1px var(--text); }

.frame-wrap iframe {
  display: block; width: 100%;
  height: max(380px, calc(100dvh - 300px));
  border: 0; border-radius: 12px;
}

/* ---------- now playing bar ---------- */

.nowbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px 8px 8px;
  background: var(--panel); border: 0; border-radius: var(--radius);
  text-align: left; cursor: pointer;
}
.nowbar:hover { background: var(--card); }
.nowbar img { width: 48px; height: 48px; border-radius: 4px; object-fit: cover; }
.nowbar span { flex: 1; min-width: 0; }
.nowbar small { display: block; color: var(--accent); font-size: 12px; font-weight: 700; }
.nowbar b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nowbar > svg { width: 24px; height: 24px; color: var(--accent); }

/* ---------- add dialog ---------- */

.add {
  width: min(460px, calc(100vw - 32px));
  padding: 24px; border: 0; border-radius: 12px;
  background: var(--card-hover); color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}
.add::backdrop { background: rgba(0, 0, 0, 0.7); }
.add h2 { margin: 0 0 8px; font-size: 22px; }
.add p { margin: 0 0 16px; color: var(--muted); }
.add p b { color: var(--text); }
.add input {
  width: 100%; padding: 12px 14px;
  background: #3e3e3e; border: 1px solid transparent; border-radius: 6px;
  color: var(--text); font: inherit;
}
.add input:focus { outline: none; border-color: var(--text); }
.add-err { margin: 10px 0 0 !important; color: #f3727f !important; }
.add-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- phone ---------- */

@media (max-width: 760px) {
  .shell {
    display: flex; flex-direction: column;
    height: auto; min-height: 100dvh;
    padding: 0 0 calc(76px + env(safe-area-inset-bottom));
    gap: 0;
  }
  .panel { border-radius: 0; }
  .nav {
    flex-direction: row; align-items: center; flex-wrap: wrap;
    padding: 12px 16px; gap: 4px;
  }
  .brand { flex: 1 1 100%; padding: 0 0 6px; }
  .nav-item { padding: 6px 12px 6px 0; font-size: 15px; gap: 8px; }
  .nav-item svg { width: 20px; height: 20px; }
  .lib { padding: 8px 0 12px; }
  .lib-head { padding: 0 16px 8px; }
  .lib-list {
    display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden;
    padding: 0 16px; scrollbar-width: none;
  }
  .lib-list li { flex: none; }
  .lib-item { width: auto; max-width: 220px; padding: 4px 14px 4px 4px; background: var(--card); border-radius: 6px; }
  .lib-item img, .lib-item .ph { width: 40px; height: 40px; }
  .main { overflow: visible; }
  .view { padding: 20px 16px; }
  .main h1 { font-size: 26px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 10px; }
  .card .play { display: none; }
  .hero { flex-direction: column; align-items: flex-start; gap: 16px; }
  .hero-art { width: 140px; height: 140px; }
  .frame-wrap iframe { height: 70vh; }
  .nowbar {
    position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 5; background: var(--card-hover);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  }
}
