/* ═══════════════════════════════════════════════
   VARIABLES
═══════════════════════════════════════════════ */
:root {
  --bg: #0c0c0c;
  --bg2: #141414;
  --bg3: #1c1c1c;
  --line: rgba(255,255,255,0.06);
  --line2: rgba(255,255,255,0.12);
  --text: #f5f5f5;
  --sub: #666;
  --sub2: #444;
  --green: #1ed760;
  --green-glow: rgba(30,215,96,0.15);
  --r: 10px;
}

/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Instrument Sans', sans-serif;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  cursor: default;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ═══════════════════════════════════════════════
   AMBIENT BACKGROUND
═══════════════════════════════════════════════ */
#ambient-bg {
  position: fixed;
  inset: -10%;
  width: 120%; height: 120%;
  background-size: cover;
  background-position: center;
  filter: blur(80px) brightness(0.3);
  z-index: -2;
  transition: background-image 1.5s ease-in-out;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════
   CANVAS BACKGROUND
═══════════════════════════════════════════════ */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════
   GRAIN OVERLAY
═══════════════════════════════════════════════ */
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.03;
  pointer-events: none;
  z-index: 9999;
}

/* ═══════════════════════════════════════════════
   SCREENS
═══════════════════════════════════════════════ */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  padding: 60px 24px 80px;
  position: relative;
  z-index: 1;
}
.screen.active { display: flex; }

/* ═══════════════════════════════════════════════
   PASSWORD SCREEN
═══════════════════════════════════════════════ */
#screen-password {
  justify-content: center;
  min-height: 100svh;
}

.pw-wordmark {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 600;
  font-size: 42px;
  letter-spacing: -2px;
  margin-bottom: 6px;
  opacity: 0;
  transform: translateY(16px);
  animation: rise 0.7s cubic-bezier(0.16,1,0.3,1) 0.1s both;
  text-align: center;
}
.pw-wordmark em { color: var(--green); font-style: normal; font-weight: 500; }

.pw-tagline {
  font-size: 13px;
  color: var(--sub);
  margin-bottom: 56px;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: rise 0.7s cubic-bezier(0.16,1,0.3,1) 0.2s both;
}

.pw-form {
  width: 100%;
  opacity: 0;
  animation: rise 0.7s cubic-bezier(0.16,1,0.3,1) 0.3s both;
}

.field {
  width: 100%;
  position: relative;
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════
   INPUTS
═══════════════════════════════════════════════ */
input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--r);
  color: var(--text);
  font-family: 'Instrument Sans', sans-serif;
  font-size: 15px;
  padding: 15px 18px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  -webkit-appearance: none;
}
input::placeholder { color: var(--sub2); }
input:focus {
  border-color: rgba(30,215,96,0.4);
  background: var(--bg3);
  box-shadow: 0 0 0 4px var(--green-glow);
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.pw-error {
  font-size: 12px;
  color: #e05a5a;
  margin-top: 10px;
  min-height: 16px;
  transition: opacity 0.2s;
  padding-left: 2px;
}

/* ═══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn {
  width: 100%;
  padding: 15px 24px;
  border-radius: var(--r);
  border: none;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, opacity 0.2s;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.08);
  opacity: 0;
  transition: opacity 0.15s;
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--green);
  color: #000;
  box-shadow: 0 4px 24px rgba(30,215,96,0.25);
  margin-top: 4px;
}
.btn-primary:hover { box-shadow: 0 8px 32px rgba(30,215,96,0.35); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; transform: none; box-shadow: none; cursor: default; }

.btn-ghost {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--line2);
}
.btn-ghost:hover { border-color: rgba(255,255,255,0.18); }

/* ═══════════════════════════════════════════════
   AUTH SCREEN
═══════════════════════════════════════════════ */
#screen-auth {
  justify-content: center;
  min-height: 100svh;
}
.auth-inner {
  width: 100%;
  text-align: center;
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) 0.1s both;
}
.auth-glyph {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--line2);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto 24px;
}
.auth-title {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 30px;
  margin-bottom: 10px;
}
.auth-sub {
  font-size: 14px;
  color: var(--sub);
  line-height: 1.7;
  margin-bottom: 36px;
}

/* ═══════════════════════════════════════════════
   MAIN APP
═══════════════════════════════════════════════ */
#screen-app {
  padding-top: 48px;
  gap: 0;
}

/* header */
.app-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 40px;
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) 0.05s both;
}
.app-wordmark {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -1px;
  line-height: 1;
}
.app-wordmark em { color: var(--green); font-style: normal; font-weight: 500; }

.now-playing {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 180px;
}
.np-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: blink 2s ease-in-out infinite;
  margin-top: 3px;
}
.np-info {
  display: flex;
  flex-direction: column;
}
.np-text {
  font-size: 11px;
  color: var(--sub);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.np-time {
  font-size: 10px;
  color: var(--sub2);
  margin-top: 2px;
}

/* search */
.search-wrap {
  width: 100%;
  position: relative;
  margin-bottom: 16px;
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) 0.12s both;
  z-index: 100;
}
.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sub);
  font-size: 16px;
  pointer-events: none;
  transition: color 0.2s;
  z-index: 1;
}
.search-wrap:focus-within .search-icon { color: var(--green); }
#search-input { padding-left: 44px; }

/* dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--r);
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.03);
  display: none;
  transform-origin: top center;
}
.dropdown.open {
  display: block;
  animation: dropIn 0.2s cubic-bezier(0.16,1,0.3,1) both;
}

.dd-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 0.12s;
}
.dd-item:last-child { border-bottom: none; }
.dd-item:hover { background: var(--bg3); }
.dd-item:active { background: rgba(30,215,96,0.06); }

.dd-art {
  width: 40px; height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg3);
}
.dd-info { flex: 1; min-width: 0; }
.dd-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.dd-artist {
  font-size: 12px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dd-dur {
  font-size: 11px;
  color: var(--sub2);
  flex-shrink: 0;
}
.dd-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--sub);
}

/* selected track bar */
.selected-bar {
  width: 100%;
  display: none;
  align-items: center;
  gap: 12px;
  background: rgba(30,215,96,0.06);
  border: 1px solid rgba(30,215,96,0.2);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 10px;
  animation: rise 0.25s cubic-bezier(0.16,1,0.3,1) both;
}
.selected-bar.visible { display: flex; }
.sel-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: #000;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sel-art {
  width: 36px; height: 36px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg3);
}
.sel-info { flex: 1; min-width: 0; }
.sel-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-artist { font-size: 12px; color: var(--sub); }

/* add section */
.add-section {
  width: 100%;
  margin-bottom: 36px;
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) 0.18s both;
}

/* divider */
.rule {
  width: 100%;
  height: 1px;
  background: var(--line);
  margin: 0 0 28px;
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) 0.22s both;
}

/* queue */
.queue-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) 0.25s both;
}
.queue-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--sub); }
.queue-count { font-size: 11px; color: var(--sub2); }

.queue-list { width: 100%; display: flex; flex-direction: column; gap: 3px; }

.q-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  animation: rise 0.35s cubic-bezier(0.16,1,0.3,1) both;
}
.q-item:hover { background: var(--bg2); border-color: var(--line); }
.q-pos { font-size: 11px; color: var(--sub2); width: 18px; text-align: center; flex-shrink: 0; }
.q-art { width: 34px; height: 34px; border-radius: 4px; object-fit: cover; flex-shrink: 0; background: var(--bg3); }
.q-info { flex: 1; min-width: 0; }
.q-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-artist { font-size: 11px; color: var(--sub); }

.q-req {
  font-size: 10px;
  color: var(--green);
  margin-top: 3px;
  opacity: 0.9;
  font-weight: 500;
}

.q-time {
  font-size: 11px;
  color: var(--sub2);
  flex-shrink: 0;
  text-align: right;
  min-width: 32px;
}

.queue-empty {
  text-align: center;
  padding: 40px 20px;
  font-size: 13px;
  color: var(--sub2);
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════
   SPINNER
═══════════════════════════════════════════════ */
.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,0.25);
  border-top-color: rgba(0,0,0,0.7);
  border-radius: 50%;
  animation: rotate 0.55s linear infinite;
  vertical-align: middle;
  margin-right: 7px;
}

/* ═══════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 100px;
  padding: 11px 20px;
  font-size: 13px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(30,215,96,0.35); color: var(--green); }
.toast.error   { border-color: rgba(224,90,90,0.35); color: #e05a5a; }

/* ═══════════════════════════════════════════════
   SIGN OUT
═══════════════════════════════════════════════ */
.signout {
  position: fixed;
  bottom: 20px;
  right: 20px;
  font-size: 11px;
  color: var(--sub2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Instrument Sans', sans-serif;
  transition: color 0.2s;
  display: none;
  z-index: 10;
}
.signout:hover { color: var(--sub); }

/* ═══════════════════════════════════════════════
   KEYFRAMES
═══════════════════════════════════════════════ */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dropIn {
  from { opacity: 0; transform: scaleY(0.92) translateY(-6px); }
  to   { opacity: 1; transform: scaleY(1) translateY(0); }
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }
@keyframes rotate { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════
   OFFLINE STATE & BIG NOW PLAYING
═══════════════════════════════════════════════ */
.offline-msg {
  text-align: center;
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--text);
  padding: 60px 20px;
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) 0.1s both;
}

.offline-msg em {
  color: var(--green);
  font-style: normal;
  font-weight: 500;
}

.now-playing-big {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) 0.2s both;
}

.np-top-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.np-big-art {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg3);
  flex-shrink: 0;
}

.np-big-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.np-big-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.np-big-artist {
  font-size: 13px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-progress {
  width: 100%;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.np-progress-bar {
  height: 100%;
  background: var(--text);
  width: 0%;
  border-radius: 2px;
  transition: width 1s linear;
}

.np-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--sub2);
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════
   HISTORY CAROUSEL
═══════════════════════════════════════════════ */
.history-section {
  width: 100%;
  margin-bottom: 24px;
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) 0.22s both;
}

.history-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none; /* Hides scrollbar in Firefox */
  -ms-overflow-style: none; /* Hides scrollbar in IE/Edge */
}

.history-carousel::-webkit-scrollbar {
  display: none; /* Hides scrollbar in Chrome/Safari/Edge */
}

.h-item {
  width: 80px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.h-art {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg3);
  border: 1px solid var(--line2);
}

.h-name {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.h-artist {
  font-size: 10px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 400px) {
  .pw-wordmark { font-size: 42px; }
  .app-wordmark { font-size: 28px; }
  .screen { padding-left: 18px; padding-right: 18px; }
}

/* ═══════════════════════════════════════════════
   EXPLICIT BADGE
═══════════════════════════════════════════════ */
.explicit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px; /* Slightly smaller for a tighter look */
  height: 13px;
  font-size: 9px;
  font-weight: 600;
  color: #a3a3a3; /* Brighter grey so it pops more */
  background: transparent;
  border: 1px solid #a3a3a3;
  border-radius: 3px;
  margin: 0 5px;
  vertical-align: middle;
  position: relative;
  top: -2px; /* Pulls it up to center it with the text */
}