/* ---------- Design tokens and reset ---------- */
:root {
  --bg: #080a0d;
  --panel: #111419;
  --panel-hover: #171b21;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f7f5;
  --muted: #8d969d;
  --accent: #b9ff45;
  --accent-dark: #0d1308;
  --player-height: 92px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: calc(var(--player-height) + 36px);
  background: radial-gradient(circle at 85% -10%, rgba(112, 255, 73, .09), transparent 30%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }

/* Subtle texture keeps the dark surface from feeling flat. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 20;
  opacity: .035;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Header and hero ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 5vw, 72px);
  border-bottom: 1px solid rgba(255,255,255,.055);
  background: rgba(8, 10, 13, .82);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-size: 14px; font-weight: 900; letter-spacing: .2em; }
.brand-mark { width: 30px; height: 30px; display: grid; grid-template-columns: repeat(3, 3px); align-items: center; justify-content: center; gap: 3px; border: 1px solid rgba(185,255,69,.35); border-radius: 50%; }
.brand-mark i { display: block; background: var(--accent); border-radius: 4px; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 17px; }
.brand-mark i:nth-child(3) { height: 12px; }
.library-count { color: #697179; font-size: 9px; text-transform: uppercase; letter-spacing: .14em; }

.hero { max-width: 1500px; margin: auto; padding: clamp(56px, 8vw, 110px) clamp(18px, 7vw, 104px) clamp(46px, 6vw, 78px); }
.eyebrow { margin: 0; color: var(--accent); font-size: 9px; font-weight: 850; letter-spacing: .22em; }
h1 { margin: 22px 0; max-width: 980px; font-size: clamp(52px, 9vw, 116px); line-height: .87; letter-spacing: -.075em; }
h1 em { color: transparent; font-style: normal; -webkit-text-stroke: 1px rgba(255,255,255,.52); }
.hero-copy { max-width: 580px; margin: 0 0 32px; color: var(--muted); font-size: clamp(13px, 1.4vw, 16px); line-height: 1.7; }

/* The search form filters instantly; submitting asks the API for a missing track. */
.search-form { width: min(760px, 100%); display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 25px 70px rgba(0,0,0,.32); }
.search-form:focus-within { border-color: rgba(185,255,69,.52); box-shadow: 0 0 0 4px rgba(185,255,69,.06), 0 25px 70px rgba(0,0,0,.32); }
.search-icon { padding-left: 10px; color: #687179; font-size: 23px; }
.search-form input { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; background: transparent; color: #fff; font-size: 14px; }
.search-submit { height: 42px; padding: 0 18px; border: 0; border-radius: 9px; background: var(--accent); color: var(--accent-dark); font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.action-button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: #b5bbc0; font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.action-button:hover, .action-button.active { border-color: rgba(185,255,69,.4); color: var(--accent); }
.action-button.primary { background: #171c19; }

/* ---------- Library grid ---------- */
.library { max-width: 1500px; margin: auto; padding: 0 clamp(18px, 5vw, 72px); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.section-heading h2 { margin: 8px 0 0; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.045em; }
.status { margin: 0; color: #707981; font-size: 10px; text-align: right; }
.status.error { color: #ff8879; }
.track-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(12px, 1.6vw, 22px); }
.track-card { min-width: 0; padding: 10px; border: 1px solid rgba(255,255,255,.07); border-radius: 14px; background: var(--panel); cursor: pointer; transition: .22s; }
.track-card:hover, .track-card:focus-visible, .track-card.playing { transform: translateY(-4px); border-color: rgba(185,255,69,.34); background: var(--panel-hover); outline: 0; }
.cover-wrap { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 9px; background: #1b2025; }
.cover-wrap img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .35s; }
.track-card:hover img { transform: scale(1.035); }
.card-play { position: absolute; right: 11px; bottom: 11px; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-dark); box-shadow: 0 8px 25px rgba(0,0,0,.4); opacity: 0; transform: translateY(7px); transition: .2s; }
.track-card:hover .card-play, .track-card:focus-visible .card-play, .track-card.playing .card-play { opacity: 1; transform: none; }
.track-copy { padding: 12px 3px 5px; min-width: 0; }
.track-copy strong, .track-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-copy strong { font-size: 12px; }
.track-copy span { margin-top: 5px; color: var(--muted); font-size: 9px; }
.track-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.source-badge { flex: 0 0 auto; padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; color: #7f8990; font-size: 7px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.source-badge.local { border-color: rgba(185,255,69,.3); color: var(--accent); }
.empty-state { grid-column: 1 / -1; padding: 70px 20px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 8px; color: #fff; font-size: 18px; }

/* ---------- Fixed custom audio player ---------- */
.player { position: fixed; z-index: 15; inset: auto 0 0; height: var(--player-height); display: grid; grid-template-columns: minmax(230px, 1fr) minmax(340px, 1.35fr) minmax(160px, 1fr); align-items: center; gap: 22px; padding: 0 clamp(14px, 3vw, 40px); border-top: 1px solid var(--line); background: rgba(13,16,20,.95); backdrop-filter: blur(22px); }
.now-playing { display: flex; align-items: center; gap: 12px; min-width: 0; }
.now-cover { width: 56px; height: 56px; flex: 0 0 auto; border-radius: 8px; object-fit: cover; background: #1d2227; }
.now-meta { min-width: 0; }
.now-meta strong, .now-meta > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-meta strong { font-size: 11px; }
.now-meta > span:last-child { margin-top: 4px; color: var(--muted); font-size: 8px; }
.now-label { margin-bottom: 5px; color: var(--accent)!important; font-size: 6px!important; letter-spacing: .17em; }
.transport { display: grid; gap: 7px; }
.transport-buttons { display: flex; align-items: center; justify-content: center; gap: 18px; }
.transport button { width: 28px; height: 28px; padding: 0; border: 0; background: transparent; color: #899199; }
.transport button:disabled { opacity: .28; cursor: not-allowed; }
.transport .play-button { width: 36px; height: 36px; border-radius: 50%; background: #f4f7f5; color: #101410; }
.timeline { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 8px; color: #687078; font-size: 8px; }
.timeline span:last-child { text-align: right; }
.range { width: 100%; height: 3px; appearance: none; border-radius: 8px; outline: 0; background: linear-gradient(to right, var(--accent) 0 var(--value, 0%), #343a40 var(--value, 0%) 100%); }
.range::-webkit-slider-thumb { width: 11px; height: 11px; appearance: none; border-radius: 50%; background: #fff; }
.range::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: #fff; }
.volume-control { display: flex; align-items: center; justify-content: flex-end; gap: 9px; color: #7c858c; }
.volume-control .range { max-width: 110px; }
.player-idle .now-cover { filter: grayscale(1); }
.sr-only { position: absolute!important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- Responsive reductions ---------- */
@media (max-width: 1100px) { .track-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 800px) {
  :root { --player-height: 80px; }
  .track-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
  .player { grid-template-columns: 1fr auto; gap: 8px; padding: 0 12px; }
  .transport { display: block; }
  .transport-buttons button:not(.play-button), .timeline, .volume-control, .player > .source-badge { display: none; }
  .now-cover { width: 50px; height: 50px; }
}
@media (max-width: 520px) {
  .library-count { display: none; }
  h1 { font-size: 50px; }
  .search-form { padding: 6px; }
  .search-submit { padding: 0 12px; }
  .track-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .track-card { padding: 8px; border-radius: 11px; }
  .card-play { width: 35px; height: 35px; }
  .status { max-width: 120px; }
  .now-meta strong { max-width: 185px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto!important; transition: none!important; } }
