/* =========================================================
   York — Tracker UI
   Design tokens lifted from Spotify's desktop dark theme:
   base #121212, sidebar #000000, elevated surface #181818,
   hover surface #282828, accent #1DB954 / hover #1ED760,
   text primary #FFFFFF, text secondary #B3B3B3.
   Font: Inter substitutes for Circular (proprietary/licensed).
   ========================================================= */

:root{
  --bg:            #121212;
  --sidebar-bg:    #000000;
  --surface:       #181818;
  --surface-hover: #282828;
  --surface-active:#2a2a2a;
  --border:        rgba(255,255,255,0.07);
  --text:          #ffffff;
  --text-sub:      #b3b3b3;
  --text-faint:    #6a6a6a;
  --accent:        #1DB954;
  --accent-hover:  #1ED760;
  --danger:        #f15e6c;
  --warn:          #e8a33d;
  --info:          #5b9bd5;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --player-h: 90px;
  --topbar-h: 64px;
  --sidebar-w: 260px;
  --font-display: 'Manrope', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:var(--font-body);
  -webkit-font-smoothing:antialiased;
  overflow:hidden;
}
svg{ fill:currentColor; width:1em; height:1em; }
button{ font-family:inherit; cursor:pointer; border:none; background:none; color:inherit; }
select, input{ font-family:inherit; }
a{ color:inherit; text-decoration:none; }
::selection{ background:var(--accent); color:#000; }

/* scrollbars */
::-webkit-scrollbar{ width:12px; height:12px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{ background:rgba(255,255,255,0.15); border-radius:8px; border:3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover{ background:rgba(255,255,255,0.3); }

.app{
  display:flex;
  height:calc(100vh - var(--player-h));
}

/* ===================== SIDEBAR ===================== */
.sidebar{
  width:var(--sidebar-w);
  flex-shrink:0;
  background:var(--sidebar-bg);
  display:flex;
  flex-direction:column;
  padding:20px 12px;
  gap:8px;
}
.sidebar-brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 12px 20px;
}
.brand-mark{
  width:32px; height:32px;
  border-radius:8px;
  background:var(--accent);
  color:#000;
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-display);
  font-weight:800;
  font-size:16px;
}
.brand-name{
  font-family:var(--font-display);
  font-weight:800;
  font-size:20px;
  letter-spacing:-0.02em;
}
.sidebar-nav{ display:flex; flex-direction:column; gap:2px; }
.nav-item{
  display:flex; align-items:center; gap:16px;
  padding:10px 12px;
  border-radius:var(--radius-sm);
  color:var(--text-sub);
  font-weight:700;
  font-size:14px;
  transition:color .15s;
}
.nav-item svg{ width:22px; height:22px; }
.nav-item:hover{ color:var(--text); }
.nav-item.active{ color:var(--text); }
.sidebar-divider{ height:1px; background:var(--border); margin:12px 4px; }
.sidebar-library-header{
  display:flex; justify-content:space-between; align-items:center;
  padding:6px 12px 8px;
  color:var(--text-sub);
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.06em;
}
.library-count{
  background:var(--surface-hover);
  color:var(--text-sub);
  border-radius:10px;
  padding:1px 8px;
  font-size:11px;
}
.sidebar-era-list{
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  gap:1px;
  flex:1;
  padding-right:2px;
}
.sidebar-era-item{
  display:flex; align-items:center; gap:10px;
  padding:7px 12px;
  border-radius:var(--radius-sm);
  color:var(--text-sub);
  font-size:13.5px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  text-align:left;
}
.sidebar-era-item:hover{ background:var(--surface); color:var(--text); }
.sidebar-era-item.active{ background:var(--surface-hover); color:var(--text); }
.sidebar-era-swatch{
  width:22px; height:22px; border-radius:4px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  font-size:10px; font-weight:800; color:rgba(0,0,0,.55);
}
.sidebar-era-name{ overflow:hidden; text-overflow:ellipsis; }

/* ===================== MAIN ===================== */
.main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width:0;
  background:linear-gradient(180deg, #1a1a1a 0%, var(--bg) 340px);
}

.topbar{
  height:var(--topbar-h);
  flex-shrink:0;
  display:flex;
  align-items:center;
  gap:16px;
  padding:0 24px;
  position:sticky; top:0; z-index:20;
  background:rgba(18,18,18,.85);
  backdrop-filter:blur(12px);
  border-bottom:1px solid transparent;
}
.pill-btn{
  width:32px; height:32px;
  border-radius:50%;
  background:rgba(0,0,0,.5);
  display:flex; align-items:center; justify-content:center;
  color:var(--text);
  flex-shrink:0;
}
.pill-btn:hover{ background:rgba(0,0,0,.7); }
.pill-btn svg{ width:20px; height:20px; }

.topbar-search{
  display:flex;
  align-items:center;
  gap:10px;
  background:var(--surface-hover);
  border-radius:22px;
  padding:0 14px;
  height:40px;
  width:360px;
  max-width:40vw;
  transition:background .15s;
}
.topbar-search:focus-within{ background:#2f2f2f; box-shadow:0 0 0 1.5px rgba(255,255,255,.5); }
.search-icon{ width:16px; height:16px; color:var(--text-sub); flex-shrink:0; }
.topbar-search input{
  background:transparent; border:none; outline:none;
  color:var(--text); font-size:14px; width:100%;
}
.topbar-search input::placeholder{ color:var(--text-sub); }
.clear-btn{ width:16px; height:16px; color:var(--text-sub); display:none; flex-shrink:0; }
.clear-btn.show{ display:block; }
.clear-btn:hover{ color:var(--text); }

.topbar-filters{ display:flex; gap:10px; margin-left:auto; }
.topbar-filters select{
  background:var(--surface-hover);
  color:var(--text);
  border:1px solid transparent;
  border-radius:20px;
  padding:8px 14px;
  font-size:13px;
  font-weight:600;
  outline:none;
  max-width:160px;
}
.topbar-filters select:hover{ background:#2f2f2f; }

.content{
  flex:1;
  overflow-y:auto;
  padding:24px 32px 40px;
}

.status-panel{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:16px; padding:120px 20px; color:var(--text-sub);
}
.spinner{
  width:40px; height:40px; border-radius:50%;
  border:3px solid rgba(255,255,255,.15);
  border-top-color:var(--accent);
  animation:spin .8s linear infinite;
}
@keyframes spin{ to{ transform:rotate(360deg); } }
.status-panel.error{ color:var(--danger); }
.status-panel .retry-btn{
  background:var(--accent); color:#000; font-weight:700;
  padding:10px 24px; border-radius:24px; margin-top:8px;
}
.status-panel .file-fallback{
  margin-top:6px; color:var(--text-sub); font-size:13px;
}
.status-panel .file-fallback label{
  color:var(--accent); cursor:pointer; text-decoration:underline;
}

.view[hidden]{ display:none; }

.section-head{ margin-bottom:20px; }
.section-head h1{
  font-family:var(--font-display);
  font-size:28px;
  font-weight:800;
  margin:0 0 4px;
  letter-spacing:-0.02em;
}
.muted{ color:var(--text-sub); font-size:14px; margin:0; }

/* ===================== ERA GRID (HOME) ===================== */
.era-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(170px, 1fr));
  gap:20px;
}
.era-card{
  background:var(--surface);
  border-radius:var(--radius-md);
  padding:14px;
  transition:background .2s;
  position:relative;
  text-align:left;
  display:block;
  width:100%;
}
.era-card:hover{ background:var(--surface-hover); }
.era-cover{
  position:relative;
  width:100%;
  aspect-ratio:1/1;
  border-radius:6px;
  overflow:hidden;
  margin-bottom:14px;
  box-shadow:0 8px 24px rgba(0,0,0,.4);
  display:flex; align-items:center; justify-content:center;
}
.era-cover .glyph{
  font-family:var(--font-display);
  font-weight:800;
  color:rgba(255,255,255,.85);
  font-size:15px;
  text-align:center;
  padding:10px;
  line-height:1.2;
  text-shadow:0 2px 6px rgba(0,0,0,.35);
}
.era-play-fab{
  position:absolute;
  right:8px; bottom:8px;
  width:44px; height:44px;
  border-radius:50%;
  background:var(--accent);
  color:#000;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 10px 20px rgba(0,0,0,.5);
  opacity:0;
  transform:translateY(8px);
  transition:opacity .2s, transform .2s, background .15s;
}
.era-card:hover .era-play-fab{ opacity:1; transform:translateY(0); }
.era-play-fab:hover{ background:var(--accent-hover); transform:scale(1.06); }
.era-play-fab svg{ width:18px; height:18px; margin-left:2px; }
.era-title{
  font-weight:700;
  font-size:15px;
  color:var(--text);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  margin-bottom:4px;
}
.era-meta{ font-size:13px; color:var(--text-sub); }

/* ===================== ERA HERO ===================== */
.era-hero{
  display:flex;
  align-items:flex-end;
  gap:24px;
  padding:32px 8px 28px;
  margin:-24px -32px 20px;
  border-radius:0 0 8px 8px;
}
.era-hero .hero-cover{
  width:180px; height:180px; border-radius:6px; flex-shrink:0;
  box-shadow:0 20px 40px rgba(0,0,0,.5);
  display:flex; align-items:center; justify-content:center;
}
.era-hero .hero-cover .glyph{
  font-family:var(--font-display); font-weight:800; font-size:26px;
  color:rgba(255,255,255,.85); text-align:center; padding:14px; line-height:1.2;
}
.hero-info{ min-width:0; }
.hero-kicker{ font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--text-sub); margin-bottom:8px; }
.hero-title{
  font-family:var(--font-display);
  font-size:clamp(28px, 4.5vw, 56px);
  font-weight:800;
  letter-spacing:-0.03em;
  margin:0 0 12px;
  line-height:1.05;
  word-break:break-word;
}
.hero-stats{ font-size:14px; color:var(--text-sub); display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
.hero-stats b{ color:var(--text); font-weight:700; }
.hero-actions{ margin-top:18px; display:flex; align-items:center; gap:20px; }
.hero-play-btn{
  width:56px; height:56px; border-radius:50%; background:var(--accent); color:#000;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 8px 20px rgba(0,0,0,.4);
}
.hero-play-btn:hover{ background:var(--accent-hover); transform:scale(1.05); }
.hero-play-btn svg{ width:24px; height:24px; margin-left:3px; }

/* ===================== TRACK LIST ===================== */
.track-list-head{
  display:grid;
  grid-template-columns: 40px 1fr 130px 120px 80px;
  gap:16px;
  padding:0 16px 8px;
  border-bottom:1px solid var(--border);
  margin-bottom:6px;
  color:var(--text-sub);
  font-size:12px;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.05em;
}
.track-list{ display:flex; flex-direction:column; }

.track-row{
  display:grid;
  grid-template-columns: 40px 1fr 130px 120px 80px;
  gap:16px;
  align-items:center;
  padding:8px 16px;
  border-radius:6px;
  transition:background .1s;
}
.track-row:hover{ background:rgba(255,255,255,.06); }
.track-row.is-playing .col-idx .idx-num{ display:none; }
.track-row.is-playing .col-idx .idx-eq{ display:flex; }
.track-row.is-playing .track-title{ color:var(--accent); }

.col-idx{ display:flex; align-items:center; justify-content:center; color:var(--text-sub); font-size:14px; position:relative; width:24px; }
.idx-num{ display:block; }
.idx-play-btn{ display:none; color:var(--text); width:16px; height:16px; }
.track-row:hover .idx-num{ display:none; }
.track-row:hover .idx-play-btn{ display:block; }
.idx-eq{ display:none; color:var(--accent); width:14px; height:14px; }
.idx-play-btn.disabled{ color:var(--text-faint); pointer-events:none; }

.col-title{ min-width:0; display:flex; flex-direction:column; gap:2px; justify-content:center; }
.track-title{
  font-size:14.5px; font-weight:500; color:var(--text);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.track-subtitle{
  font-size:12.5px; color:var(--text-sub);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.track-era-tag{ color:var(--text-faint); }
.track-era-tag::before{ content:'· '; }

.col-status{ min-width:0; }
.status-badge{
  display:inline-flex; align-items:center; gap:5px;
  font-size:11.5px; font-weight:700;
  padding:3px 9px; border-radius:20px;
  white-space:nowrap;
}
.status-full{ background:rgba(29,185,84,.15); color:#3be07a; }
.status-partial{ background:rgba(232,163,61,.15); color:var(--warn); }
.status-snippet{ background:rgba(91,155,213,.15); color:var(--info); }
.status-unavailable{ background:rgba(241,94,108,.15); color:var(--danger); }
.status-og{ background:rgba(255,255,255,.1); color:var(--text-sub); }

.col-date, .col-len{ font-size:13px; color:var(--text-sub); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.col-actions{ display:flex; justify-content:flex-end; gap:8px; }
.link-icon-btn{ width:28px; height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center; color:var(--text-sub); flex-shrink:0; }
.link-icon-btn:hover{ color:var(--text); background:var(--surface-hover); }
.link-icon-btn svg{ width:15px; height:15px; }

.track-notes-toggle{ color:var(--text-faint); }
.track-row .track-title-wrap{ display:flex; align-items:center; gap:8px; cursor:pointer; }
.notes-expand{
  grid-column: 1 / -1;
  padding:4px 16px 14px 56px;
  font-size:13px; line-height:1.5; color:var(--text-sub);
  display:none;
}
.notes-expand.open{ display:block; }

.load-more-btn{
  margin:24px auto 0;
  display:block;
  background:transparent;
  border:1px solid var(--text-sub);
  color:var(--text);
  padding:10px 28px;
  border-radius:24px;
  font-weight:700;
  font-size:13px;
}
.load-more-btn:hover{ border-color:var(--text); transform:scale(1.02); }

/* ===================== PLAYER BAR ===================== */
.player-bar{
  position:fixed;
  left:0; right:0; bottom:0;
  height:var(--player-h);
  background:var(--sidebar-bg);
  border-top:1px solid var(--border);
  display:grid;
  grid-template-columns: minmax(180px, 1fr) minmax(300px, 2fr) minmax(160px, 1fr);
  align-items:center;
  padding:0 16px;
  gap:16px;
  z-index:100;
}
.player-track-info{ display:flex; align-items:center; gap:12px; min-width:0; }
.player-cover{
  width:56px; height:56px; border-radius:4px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 10px rgba(0,0,0,.4);
}
.player-cover .glyph{ font-family:var(--font-display); font-weight:800; font-size:11px; color:rgba(255,255,255,.85); text-align:center; padding:4px; line-height:1.1; }
.player-text{ min-width:0; }
.player-title{ font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.player-era{ font-size:12px; color:var(--text-sub); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }

.player-center{ display:flex; flex-direction:column; align-items:center; gap:6px; min-width:0; }
.player-controls{ display:flex; align-items:center; gap:18px; }
.play-btn{
  width:34px; height:34px; border-radius:50%;
  background:#fff; color:#000;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.play-btn:hover{ transform:scale(1.06); }
.play-btn svg{ width:16px; height:16px; }
.player-seek-row{ display:flex; align-items:center; gap:10px; width:100%; }
.time-label{ font-size:11px; color:var(--text-sub); width:34px; flex-shrink:0; }
.time-label:last-child{ text-align:left; }
.time-label:first-child{ text-align:right; }

input[type="range"]{
  -webkit-appearance:none;
  appearance:none;
  width:100%;
  height:4px;
  border-radius:2px;
  background:rgba(255,255,255,.25);
  outline:none;
  cursor:pointer;
}
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none;
  width:12px; height:12px; border-radius:50%;
  background:#fff;
  opacity:0;
  transition:opacity .1s;
}
.player-seek-row:hover input::-webkit-slider-thumb,
.player-extras:hover input::-webkit-slider-thumb{ opacity:1; }
#seekBar{ accent-color: var(--text); }
#seekBar::-webkit-slider-runnable-track{ background: linear-gradient(to right, #fff var(--progress,0%), rgba(255,255,255,.25) 0%); border-radius:2px; height:4px; }

.player-extras{ display:flex; align-items:center; gap:12px; justify-content:flex-end; }
.pill-link{ width:32px; height:32px; border-radius:50%; display:flex; align-items:center; justify-content:center; color:var(--text-sub); }
.pill-link:hover{ color:var(--text); background:var(--surface-hover); }
.vol-icon{ color:var(--text-sub); width:18px; height:18px; flex-shrink:0; }
#volumeBar{ width:90px; }
#volumeBar::-webkit-slider-runnable-track{ background: linear-gradient(to right, #fff var(--vol,80%), rgba(255,255,255,.25) 0%); border-radius:2px; height:4px; }

/* ===================== MOBILE NAV ===================== */
.mobile-nav{ display:none; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px){
  :root{ --sidebar-w: 0px; }
  .sidebar{ display:none; }
  .topbar-filters{ display:none; }
  .content{ padding:16px 16px 90px; }
  .era-grid{ grid-template-columns:repeat(auto-fill, minmax(130px, 1fr)); gap:14px; }
  .era-hero{ flex-direction:column; align-items:flex-start; margin:-16px -16px 16px; padding:20px 16px; }
  .era-hero .hero-cover{ width:130px; height:130px; }
  .track-list-head{ grid-template-columns: 28px 1fr 70px; }
  .track-list-head .col-date, .track-list-head .col-len{ display:none; }
  .track-row{ grid-template-columns: 28px 1fr 70px; padding:8px; }
  .col-date, .col-len{ display:none; }
  .player-bar{ grid-template-columns:1fr auto; padding:8px 12px; height:64px; }
  .player-center{ display:none; }
  .player-extras{ display:none; }
  .app{ height:calc(100vh - 64px - 56px); }
  .mobile-nav{
    display:flex; position:fixed; left:0; right:0; bottom:64px;
    height:56px; background:#000; border-top:1px solid var(--border);
    z-index:99;
  }
  .mnav-item{
    flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:2px; font-size:10px; color:var(--text-sub); font-weight:600;
  }
  .mnav-item svg{ width:20px; height:20px; }
  .mnav-item.active{ color:var(--text); }
}
@media (min-width: 901px){
  .player-bar[hidden]{ display:none; }
}
