/* Trackbee — design system + layout (contract v0 tokens) */
:root {
  --bg: #0e0e10;
  --card: #17171b;
  --border: #26262c;
  --text: #f2f0eb;
  --text-dim: #b8b8c0;
  --muted: #8b8b93;
  --coral: #ff5a3c;
  --coral-ink: #14100e;
  --ok: #8ce3a4;
  --warn: #ffcf6b;
  --tabbar-h: 64px;
  --mini-h: 62px;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.accent { color: var(--coral); }
.error { color: var(--coral); font-size: 13px; margin-top: 10px; }

/* ── shared ── */
.brand { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.brand.sm { font-size: 18px; }
.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 100ms ease, background 120ms ease, border-color 120ms ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--coral); border-color: var(--coral); color: var(--coral-ink); width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-skip { flex: 1; background: transparent; border-color: rgba(255, 255, 255, 0.18); color: var(--text-dim); }
.btn-keep { flex: 1; background: var(--coral); border-color: var(--coral); color: var(--coral-ink); }
.btn-round {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--coral); border-color: var(--coral); color: var(--coral-ink);
  font-size: 20px; padding: 0;
  box-shadow: 0 4px 18px rgba(255, 90, 60, 0.35);
}
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
  border: 1px solid var(--border); color: var(--muted);
}
.pill.src-dispersion { color: var(--warn); border-color: var(--warn); }
.pill.src-inflyte { color: var(--coral); border-color: var(--coral); }
.pill.src-trackstack { color: var(--ok); border-color: var(--ok); }
.pill.match-hi { color: var(--ok); border-color: var(--ok); }
.pill.match-mid { color: var(--warn); border-color: var(--warn); }
.pill.dot-live { color: var(--ok); border-color: var(--ok); }
.pill.dot-attention { color: var(--warn); border-color: var(--warn); }
.pill.dot-expired { color: var(--coral); border-color: var(--coral); }

/* ── auth ── */
#auth-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .tagline { color: var(--muted); margin: 6px 0 28px; }
.auth-card label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.auth-card input {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); padding: 14px; font-size: 16px;
  outline: none;
}
.auth-card input:focus { border-color: var(--coral); }
.auth-card .btn { margin-top: 14px; }
#auth-code { letter-spacing: 8px; text-align: center; font-size: 24px; }

/* ── app frame ── */
#app-view { max-width: 720px; margin: 0 auto; padding: 0 16px calc(var(--tabbar-h) + var(--mp-h, var(--mini-h)) + 24px); }
#app-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 0 10px;
}
#header-context { font-size: 12px; }
.pane-title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0 14px; }
.pane-actions { margin-bottom: 14px; }

/* ── track list (Today queue / Keepers) — Spotify playlist pattern: flat rows, art is the hero ── */
.track-list { display: flex; flex-direction: column; gap: 2px; }
.track-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px; margin: 0 -8px;
  background: transparent; border: none; border-radius: 10px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background 120ms ease;
}
.track-row:active { background: #1e1e24; }
.track-row.playing { background: rgba(255, 90, 60, 0.07); }
.track-rank {
  font-size: 11px; font-weight: 600; color: var(--muted); opacity: 0.55;
  min-width: 16px; text-align: center; font-variant-numeric: tabular-nums;
}
.track-artwrap { position: relative; width: 52px; height: 52px; flex-shrink: 0; }
.track-art {
  width: 52px; height: 52px; border-radius: var(--radius-sm); flex-shrink: 0;
  object-fit: cover; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.track-artwrap .track-art-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #26262c, #2b1712);
  color: var(--coral); font-weight: 800; font-size: 18px;
  border-radius: var(--radius-sm);
}
/* animated equalizer bars over the artwork of the now-playing row */
.track-eq {
  position: absolute; inset: 0;
  display: none; align-items: flex-end; justify-content: center;
  gap: 3px; padding: 7px 0;
  background: rgba(8, 8, 10, 0.42); border-radius: var(--radius-sm);
}
.track-row.playing .track-eq { display: flex; }
.track-eq i {
  width: 3.5px; border-radius: 2px; background: var(--coral);
  animation: tb-eq 0.9s ease-in-out infinite;
}
.track-eq i:nth-child(2) { animation-delay: 0.25s; animation-duration: 1.1s; }
.track-eq i:nth-child(3) { animation-delay: 0.5s; animation-duration: 0.8s; }
@keyframes tb-eq { 0%, 100% { height: 20%; } 50% { height: 85%; } }
body:not(.is-playing) .track-eq i { animation-play-state: paused; }
.track-main { flex: 1; min-width: 0; }
.track-title {
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-row.playing .track-title { color: var(--coral); }
.track-sub {
  font-size: 12.5px; color: var(--muted); margin-top: 1px;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; min-width: 0; gap: 6px;
}
.track-sub-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* BPM + key are primary DJ metadata — they NEVER truncate */
.track-sub-tech { white-space: nowrap; flex-shrink: 0; color: #a6a6ae; }
.track-sub-tech::before { content: "· "; color: var(--muted); }
.track-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.match-badge { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.match-badge.match-hi { color: var(--ok); }
.match-badge.match-mid { color: var(--warn); }
.match-badge.match-lo { color: var(--muted); }
.track-meta .pill { border: none; padding: 0; font-size: 11px; color: var(--muted); background: none; }
.synced-badge { color: var(--ok); font-size: 11px; }

/* ── empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .big { font-size: 40px; margin-bottom: 12px; }
.empty-state h2 { color: var(--text); font-size: 18px; margin-bottom: 6px; }

/* ── sources ── */
#sources-list { display: flex; flex-direction: column; gap: 8px; }
.source-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.source-row .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.dot-live { background: var(--ok); }
.dot.dot-attention { background: var(--warn); }
.dot.dot-expired { background: var(--coral); }
.source-main { flex: 1; min-width: 0; }
.source-name { font-weight: 700; text-transform: capitalize; }
.source-detail { font-size: 12px; color: var(--muted); }
.source-last { font-size: 11px; color: var(--muted); }

/* ── settings ── */
.settings-row { display: flex; justify-content: space-between; padding: 6px 0 14px; }

/* ── tab bar ── */
#tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar-h);
  display: flex;
  background: rgba(14, 14, 16, 0.82);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.tab-btn {
  flex: 1; background: none; border: none; color: #b0b0b8;
  font-size: 11px; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn .tab-ico { font-size: 19px; }
.tab-btn.active { color: var(--coral); }

/* ── player bar (always visible; expands upward in place) ── */
#mini-player {
  position: fixed; left: 0; right: 0; bottom: var(--tabbar-h);
  background: rgba(20, 20, 24, 0.88);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  z-index: 41;
  display: flex; flex-direction: column;
}
#mp-head {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: var(--mini-h); padding: 0 12px; cursor: pointer;
}
.mp-art {
  width: 44px; height: 44px; border-radius: 6px; flex-shrink: 0;
  object-fit: cover; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); cursor: pointer;
}
.mp-art-fallback {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #26262c, #2b1712);
  color: var(--coral); font-weight: 800; font-size: 16px;
}
.mp-btn {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--coral); border: none; color: var(--coral-ink); font-size: 14px; cursor: pointer;
  box-shadow: 0 2px 10px rgba(255, 90, 60, 0.35);
}
.mp-info { flex: 1; min-width: 0; }
.mp-title {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-artist { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-chevron {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 6px 8px; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.mp-chevron:active { color: var(--coral); }
#mp-progress { position: absolute; left: 0; right: 0; top: 0; height: 2.5px; background: rgba(255, 255, 255, 0.12); }
#mp-progress-fill { height: 100%; width: 0%; background: var(--coral); }

/* expanded section — blurred artwork backdrop behind the controls */
/* when the bar is expanded, JS measures its real height into --mp-h (see app.js playerBar); app-view clearance uses it */
#mp-expanded {
  position: relative; overflow: hidden;
  padding: 14px 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, #1c1310, #141416);
}
#mp-expanded::before {
  content: ''; position: absolute; inset: -40px;
  background-image: var(--art-url, none);
  background-size: cover; background-position: center;
  filter: blur(34px) saturate(1.6) brightness(0.75);
  opacity: 0.85;
}
#mp-expanded > * { position: relative; z-index: 1; }
.wave-strip {
  width: 100%; height: 52px; display: block;
  background: rgba(0, 0, 0, 0.25); border: none;
  border-radius: 8px; cursor: pointer;
}
.mp-progress-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; font-variant-numeric: tabular-nums;
}
#mp-seek { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); cursor: pointer; }
#mp-seek-fill { height: 100%; width: 0%; border-radius: 2px; background: var(--coral); }
.mp-controls { position: relative; display: flex; align-items: center; justify-content: center; gap: 26px; }
.mp-controls .btn-round { width: 56px; height: 56px; font-size: 18px; box-shadow: 0 4px 18px rgba(255, 90, 60, 0.4); }
.mp-controls #mp-fwd30 { position: absolute; right: 10px; }
.mp-ctl {
  background: none; border: none; color: var(--text-dim);
  font-size: 16px; font-weight: 700; cursor: pointer; padding: 10px;
  -webkit-tap-highlight-color: transparent;
}
.mp-ctl:active { color: var(--coral); }
.mp-actions { display: flex; gap: 10px; }
.mp-actions .btn { padding: 13px 14px; font-size: 15px; border-radius: var(--radius); }

/* ── onboarding ── */
#onboarding-view {
  min-height: 100vh; display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 20px 32px; overflow-y: auto;
}
.ob-card { width: 100%; max-width: 480px; }
.stepper { display: flex; gap: 6px; margin: 14px 0 26px; }
.step-seg { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.step-seg.active { background: var(--coral); }
.step-seg.done { background: var(--ok); }
.ob-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.ob-sub { font-size: 14px; margin-bottom: 18px; }
.ob-label { display: block; font-size: 13px; color: var(--muted); margin: 16px 0 6px; }
.ob-select {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); padding: 12px 14px; font-size: 15px;
  outline: none; appearance: none;
}
.ob-select:focus { border-color: var(--coral); }
#ob-portals { display: flex; flex-direction: column; gap: 12px; }
.portal-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.portal-head { display: flex; align-items: center; justify-content: space-between; }
.portal-status { font-size: 12px; }
.portal-status.ok { color: var(--ok); }
.portal-status.error { color: var(--coral); }
.portal-card input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 12px 14px; font-size: 15px; outline: none;
}
.portal-card input:focus { border-color: var(--coral); }
.portal-row { display: flex; gap: 10px; }
.portal-row .ob-select { flex: 1; }
.portal-row .ob-connect { flex: 1; margin: 0; }
.ob-skip-link {
  display: block; width: 100%; margin: 0 0 16px; padding: 12px;
  background: none; border: 1px dashed var(--coral); border-radius: var(--radius);
  color: var(--coral);
  font-size: 15px; font-weight: 600; text-align: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dest-picker { display: flex; gap: 10px; }
.dest-card {
  flex: 1; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  color: var(--text); -webkit-tap-highlight-color: transparent;
}
.dest-card.selected { border-color: var(--coral); }
.dest-name { font-weight: 700; font-size: 15px; }
.dest-sub { font-size: 12px; }
#ob-finish { margin-top: 22px; }
#ob-back { margin-top: 8px; width: 100%; }

/* ── now playing — green-room feel: blurred artwork backdrop, hero art, centered transport ── */
#now-playing {
  position: fixed; inset: 0; z-index: 60;
  background: radial-gradient(120% 80% at 50% 0%, #1a1412, var(--bg) 62%);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 22px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.np-backdrop {
  position: fixed; inset: -60px; pointer-events: none;
  background-image: linear-gradient(180deg, rgba(14, 14, 16, 0.25), rgba(14, 14, 16, 0.9) 80%), var(--art-url, none);
  background-size: cover; background-position: center;
  filter: blur(60px) saturate(1.5);
}
#now-playing > *:not(.np-backdrop) { position: relative; z-index: 1; }
.np-head { width: 100%; max-width: 560px; display: flex; justify-content: space-between; align-items: center; }
#np-art {
  width: min(74vw, 320px); height: auto; aspect-ratio: 1;
  border-radius: 16px; margin: auto 0 18px; /* auto top margin shares free space with .np-actions */
  background: linear-gradient(135deg, #26262c, #17171b 60%, #2b1712);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
#np-art-img { width: 100%; height: 100%; object-fit: cover; }
#np-art-initials { font-size: 56px; font-weight: 800; color: var(--coral); opacity: 0.85; }
.np-meta { text-align: center; }
.np-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.np-artist { font-size: 14px; margin-top: 3px; }
#np-canvas {
  width: 100%; max-width: 560px; height: 96px; margin: 16px 0 8px;
  background: rgba(0, 0, 0, 0.28); border: none;
  border-radius: var(--radius); cursor: pointer;
}
.np-progress-row {
  width: 100%; max-width: 560px; display: flex; align-items: center; gap: 10px;
  font-size: 11px; font-variant-numeric: tabular-nums;
}
#np-progress { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); cursor: pointer; }
#np-progress-fill { height: 100%; width: 0%; border-radius: 2px; background: var(--coral); }
.np-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 14px 0 4px; }
.np-tags .pill { font-variant-numeric: tabular-nums; }
.np-transport {
  position: relative; width: 100%; max-width: 560px;
  display: flex; align-items: center; justify-content: center; margin-top: 12px;
}
.np-transport #np-fwd30 {
  position: absolute; right: 24px;
  font-size: 13px; color: var(--muted); padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 999px;
}
.np-actions { width: 100%; max-width: 560px; display: flex; gap: 12px; margin-top: auto; padding-top: 20px; }
.np-actions .btn { padding: 15px 16px; font-size: 15.5px; border-radius: 14px; }

/* ── toast ── */
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--mini-h) + 12px);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  z-index: 70; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: toast-in 160ms ease-out;
}
#toast .btn { padding: 6px 10px; font-size: 13px; color: var(--coral); flex-shrink: 0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── offline bar ── */
#offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  background: var(--warn); color: #14100e;
  font-size: 12px; font-weight: 600; text-align: center; padding: 6px 12px;
}

/* ── LANE-F2 state overlay ── */
#state-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
#state-overlay .state-fallback h2 { font-size: 20px; margin-bottom: 8px; }
#state-overlay .state-fallback p { color: var(--muted); }

/* ── desktop ── */
@media (hover: hover) {
  .track-row:hover { background: #17171c; }
  .track-row.playing:hover { background: rgba(255, 90, 60, 0.1); }
}
@media (min-width: 900px) {
  #tab-bar { left: 50%; transform: translateX(-50%); max-width: 720px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  #mini-player { left: 50%; transform: translateX(-50%); max-width: 720px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  #toast { left: 50%; right: auto; transform: translateX(-50%); width: 420px; }
}
