/* =============================================================
   CRATOORA NEEDLE — needleStyles.css
   Light DOM styles for: shell, modals, player bar,
   preview banner, update banner, sidebar backdrop,
   create dropdown, collection flyout, crate auth gate.
   Web component internals live in their own shadow styles().
   Target: iOS/Safari + Windows/Android (-webkit- throughout)
   ============================================================= */

/* ── Shell ── */
body.stereo-layout {
  overflow: hidden;
  height: 100dvh;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  background: #0a0a0a;
}

.stereo-shell {
  display: -webkit-flex !important;
  display: flex !important;
  -webkit-flex: 1 !important;
  flex: 1 !important;
  background: #0a0a0a !important;
  gap: 0.5rem !important;
  padding: 0.5rem !important;
  -webkit-box-sizing: border-box !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  height: calc(100dvh - 0px) !important;
}

cratoora-needle-sidebar {
  border-radius: 10px;
}

cratoora-needle-main-view {
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
  border-radius: 10px;
  overflow: hidden;
}

/* ── Mobile shell ── */
@media (max-width: 768px) {
  body.stereo-layout { overflow: auto; }
  .stereo-shell {
    -webkit-flex-direction: column !important;
    flex-direction: column !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    gap: 0 !important;
  }
  cratoora-needle-sidebar { border-radius: 0; }
  cratoora-needle-main-view { border-radius: 0; }
}

/* ── Mobile sidebar backdrop ── */
#sidebarBackdrop {
  display: none;
  position: fixed; inset: 0; z-index: 199;
  background: rgba(0,0,0,0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  -webkit-transition: opacity 0.3s ease; transition: opacity 0.3s ease;
}
#sidebarBackdrop.visible { opacity: 1; pointer-events: auto; }
@media (max-width: 768px) { #sidebarBackdrop { display: block; } }

/* ══════════════════════════════════════════════
   CREATE DROPDOWN  (appended to body by JS)
══════════════════════════════════════════════ */
.sp-create-dd {
  position: fixed;
  z-index: 1000;
  background: #282828;
  border-radius: 6px;
  padding: 0.3rem 0;
  min-width: 210px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.75);
  opacity: 0; pointer-events: none;
  -webkit-transform: scale(0.95) translateY(-4px);
  transform: scale(0.95) translateY(-4px);
  -webkit-transition: opacity 0.16s, -webkit-transform 0.16s cubic-bezier(0.23,1,0.32,1);
  transition: opacity 0.16s, transform 0.16s cubic-bezier(0.23,1,0.32,1);
}
.sp-create-dd.open {
  opacity: 1; pointer-events: auto;
  -webkit-transform: scale(1) translateY(0);
  transform: scale(1) translateY(0);
}
.sp-dd-item {
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  gap: 0.85rem; padding: 0.72rem 1rem;
  cursor: pointer;
  -webkit-transition: background 0.12s; transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.sp-dd-item:hover { background: rgba(255,255,255,0.1); }
.sp-dd-icon {
  width: 38px; height: 38px; border-radius: 6px;
  background: #3e3e3e; display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  -webkit-flex-shrink: 0; flex-shrink: 0; color: rgba(255,255,255,0.8);
}
.sp-dd-label { font-family: 'Syne', sans-serif; font-size: 0.85rem; font-weight: 700; color: #fff; }
.sp-dd-sub   { font-family: 'Outfit', sans-serif; font-size: 0.7rem; color: rgba(255,255,255,0.42); margin-top: 1px; }

/* ══════════════════════════════════════════════
   COLLECTION FLYOUT  (appended to body by JS)
══════════════════════════════════════════════ */
.sp-lib-submenu {
  position: fixed;
  width: 200px; background: #282828;
  border-radius: 8px; padding: 0.35rem 0;
  box-shadow: 0 16px 48px rgba(0,0,0,0.75);
  opacity: 0; pointer-events: none;
  -webkit-transform: translateX(-6px);
  transform: translateX(-6px);
  -webkit-transition: opacity 0.18s ease, -webkit-transform 0.18s cubic-bezier(0.23,1,0.32,1);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.23,1,0.32,1);
  z-index: 2000;
}
.sp-lib-submenu.flyout-visible {
  opacity: 1; pointer-events: auto;
  -webkit-transform: translateX(0); transform: translateX(0);
}
.sp-lib-sub-item {
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  gap: 0.9rem; padding: 0.7rem 1.1rem;
  font-family: 'Outfit', sans-serif; font-size: 0.88rem; font-weight: 600;
  color: rgba(255,255,255,0.78); text-decoration: none; cursor: pointer;
  white-space: nowrap;
  -webkit-transition: background 0.12s, color 0.12s;
  transition: background 0.12s, color 0.12s;
}
.sp-lib-sub-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sp-lib-sub-item svg { -webkit-flex-shrink: 0; flex-shrink: 0; opacity: 0.65; -webkit-transition: opacity 0.12s; transition: opacity 0.12s; }
.sp-lib-sub-item:hover svg { opacity: 1; }

/* ══════════════════════════════════════════════
   CREATE CRATE MODAL
══════════════════════════════════════════════ */
.create-crate-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.75);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  padding: 1.25rem; opacity: 0; pointer-events: none;
  -webkit-transition: opacity 0.22s ease; transition: opacity 0.22s ease;
}
.create-crate-overlay.open { opacity: 1; pointer-events: auto; }

.create-crate-modal {
  width: min(360px, 100%); background: #282828; border-radius: 16px;
  padding: 1.5rem; box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  -webkit-transform: scale(0.95); transform: scale(0.95);
  -webkit-transition: -webkit-transform 0.25s cubic-bezier(0.23,1,0.32,1);
  transition: transform 0.25s cubic-bezier(0.23,1,0.32,1);
}
.create-crate-overlay.open .create-crate-modal { -webkit-transform: scale(1); transform: scale(1); }

.create-crate-header { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: space-between; justify-content: space-between; margin-bottom: 1.1rem; }
.create-crate-title { font-family: 'Syne', sans-serif; font-size: 1.05rem; font-weight: 800; color: #fff; }
.create-crate-close { width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.55); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; cursor: pointer; font-size: 0.7rem; font-family: inherit; -webkit-transition: background 0.15s, color 0.15s; transition: background 0.15s, color 0.15s; }
.create-crate-close:hover { background: rgba(255,255,255,0.18); color: #fff; }

.create-crate-input { width: 100%; background: #3e3e3e; border: none; border-radius: 6px; padding: 0.65rem 0.75rem; font-family: 'Outfit', sans-serif; font-size: 0.88rem; color: #fff; outline: none; margin-bottom: 0.65rem; -webkit-box-sizing: border-box; box-sizing: border-box; }
.create-crate-input::-webkit-input-placeholder { color: rgba(255,255,255,0.3); }
.create-crate-input::placeholder { color: rgba(255,255,255,0.3); }
.create-crate-input:focus { background: #444; }

.create-crate-actions { display: -webkit-flex; display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.btn-crate-cancel { -webkit-flex: 1; flex: 1; padding: 0.68rem; border-radius: 999px; background: none; border: 1px solid rgba(255,255,255,0.15); font-family: 'Outfit', sans-serif; font-size: 0.85rem; font-weight: 700; color: rgba(255,255,255,0.6); cursor: pointer; -webkit-transition: background 0.15s; transition: background 0.15s; }
.btn-crate-cancel:hover { background: rgba(255,255,255,0.07); }
.btn-crate-create { -webkit-flex: 1; flex: 1; padding: 0.68rem; border-radius: 999px; background: #fff; border: none; font-family: 'Outfit', sans-serif; font-size: 0.85rem; font-weight: 800; color: #080808; cursor: pointer; -webkit-transition: background 0.15s; transition: background 0.15s; }
.btn-crate-create:hover { background: rgba(255,255,255,0.88); }

/* ══════════════════════════════════════════════
   CRATE AUTH GATE MODAL
══════════════════════════════════════════════ */
.crate-auth-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,0.65);
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  opacity: 0; pointer-events: none;
  -webkit-transition: opacity 0.22s ease; transition: opacity 0.22s ease;
}
.crate-auth-overlay.open { opacity: 1; pointer-events: auto; }

.crate-auth-modal {
  background: #1a1a1a; border-radius: 12px; width: min(400px, 90vw);
  padding: 2.5rem 2rem 2rem;
  display: -webkit-flex; display: flex;
  -webkit-flex-direction: column; flex-direction: column;
  -webkit-align-items: center; align-items: center;
  text-align: center; position: relative;
  -webkit-transform: scale(0.94); transform: scale(0.94);
  -webkit-transition: -webkit-transform 0.25s cubic-bezier(0.23,1,0.32,1);
  transition: transform 0.25s cubic-bezier(0.23,1,0.32,1);
}
.crate-auth-overlay.open .crate-auth-modal { -webkit-transform: scale(1); transform: scale(1); }

.crate-auth-close { position: absolute; top: 1rem; right: 1rem; width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.6); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; cursor: pointer; font-size: 0.72rem; font-family: inherit; -webkit-transition: background 0.15s, color 0.15s; transition: background 0.15s, color 0.15s; }
.crate-auth-close:hover { background: rgba(255,255,255,0.18); color: #fff; }
.crate-auth-logo { width: 48px; height: 48px; border-radius: 10px; margin-bottom: 1.25rem; display: block; }
.crate-auth-title { font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 800; color: #fff; letter-spacing: -0.02em; margin-bottom: 0.5rem; line-height: 1.3; }
.crate-auth-sub { font-family: 'Outfit', sans-serif; font-size: 0.82rem; color: rgba(255,255,255,0.5); line-height: 1.5; margin-bottom: 1.75rem; max-width: 28ch; }
.crate-auth-actions { display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; gap: 0.6rem; width: 100%; }
.btn-crate-auth-signup { width: 100%; padding: 0.82rem; background: #fff; color: #080808; border: none; border-radius: 999px; font-family: 'Outfit', sans-serif; font-size: 0.9rem; font-weight: 800; cursor: pointer; text-decoration: none; display: block; text-align: center; -webkit-transition: background 0.15s; transition: background 0.15s; -webkit-tap-highlight-color: transparent; }
.btn-crate-auth-signup:hover { background: rgba(255,255,255,0.88); }
.btn-crate-auth-login { width: 100%; padding: 0.8rem; background: rgba(255,255,255,0.08); color: #fff; border: none; border-radius: 999px; font-family: 'Outfit', sans-serif; font-size: 0.9rem; font-weight: 700; cursor: pointer; text-decoration: none; display: block; text-align: center; -webkit-transition: background 0.15s; transition: background 0.15s; -webkit-tap-highlight-color: transparent; }
.btn-crate-auth-login:hover { background: rgba(255,255,255,0.14); }

/* ══════════════════════════════════════════════
   PLAYER BAR
══════════════════════════════════════════════ */
.player-bar {
  position: fixed !important; inset-inline: 0 !important;
  bottom: 0 !important; z-index: 300 !important;
  background: #181818 !important;
  border-top: 1px solid #2a2a2a !important;
  height: 90px !important;
  display: -webkit-flex !important; display: flex !important;
  -webkit-align-items: center !important; align-items: center !important;
  padding: 0 1.5rem !important; gap: 1rem !important;
  -webkit-transform: translateY(100%) !important;
  transform: translateY(100%) !important;
  -webkit-transition: -webkit-transform 0.4s cubic-bezier(0.23,1,0.32,1) !important;
  transition: transform 0.4s cubic-bezier(0.23,1,0.32,1) !important;
  padding-bottom: calc(0px + env(safe-area-inset-bottom, 0px)) !important;
}
.player-bar.visible { -webkit-transform: translateY(0) !important; transform: translateY(0) !important; }

.player-progress { position: absolute !important; top: 0 !important; left: 0 !important; right: 0 !important; height: 3px !important; background: rgba(255,255,255,0.08) !important; cursor: pointer !important; }
.player-progress-fill { height: 100% !important; width: 0% !important; background: #8B5CF6 !important; -webkit-transition: width 0.5s linear !important; transition: width 0.5s linear !important; pointer-events: none !important; }

.player-thumb { width: 52px !important; height: 52px !important; border-radius: 6px !important; background: linear-gradient(135deg,#8B5CF6,#D97706) !important; display: -webkit-flex !important; display: flex !important; -webkit-align-items: center !important; align-items: center !important; -webkit-justify-content: center !important; justify-content: center !important; font-size: 1.4rem !important; -webkit-flex-shrink: 0 !important; flex-shrink: 0 !important; box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important; }
.player-info { -webkit-flex: 1 !important; flex: 1 !important; min-width: 0 !important; }
.player-title { font-family: 'Outfit', sans-serif !important; font-size: 0.88rem !important; font-weight: 700 !important; color: #fff !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.player-artist { font-family: 'Outfit', sans-serif !important; font-size: 0.72rem !important; color: rgba(255,255,255,0.5) !important; margin-top: 2px !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }

.player-controls { display: -webkit-flex !important; display: flex !important; -webkit-align-items: center !important; align-items: center !important; gap: 0.35rem !important; -webkit-flex-shrink: 0 !important; flex-shrink: 0 !important; }
.player-btn { width: 36px !important; height: 36px !important; border-radius: 50% !important; border: none !important; background: none !important; color: rgba(255,255,255,0.65) !important; display: -webkit-flex !important; display: flex !important; -webkit-align-items: center !important; align-items: center !important; -webkit-justify-content: center !important; justify-content: center !important; cursor: pointer !important; -webkit-transition: color 0.15s, background 0.15s !important; transition: color 0.15s, background 0.15s !important; -webkit-tap-highlight-color: transparent !important; }
.player-btn:hover { color: #fff !important; background: rgba(255,255,255,0.08) !important; }
.player-btn.play-pause { width: 42px !important; height: 42px !important; background: #fff !important; color: #080808 !important; }
.player-btn.play-pause:hover { background: rgba(255,255,255,0.88) !important; color: #080808 !important; }

/* Play/pause icon swap */
#playerPlayPause[data-playing="true"]  #iconPlay  { display: none !important; }
#playerPlayPause[data-playing="true"]  #iconPause { display: block !important; }
#playerPlayPause[data-playing="false"] #iconPlay  { display: block !important; }
#playerPlayPause[data-playing="false"] #iconPause { display: none !important; }

body.player-active { padding-bottom: 90px; }

/* ══════════════════════════════════════════════
   PREVIEW BANNER
══════════════════════════════════════════════ */
.cr-preview-banner {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 250;
  background: #1d1d1d; border-top: 1px solid rgba(255,255,255,0.1);
  padding: 0.85rem 1.5rem;
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: space-between; justify-content: space-between;
  gap: 1rem;
  -webkit-transform: translateY(100%); transform: translateY(100%);
  -webkit-transition: -webkit-transform 0.45s cubic-bezier(0.23,1,0.32,1);
  transition: transform 0.45s cubic-bezier(0.23,1,0.32,1);
}
.cr-preview-banner.visible { -webkit-transform: translateY(0); transform: translateY(0); }
.cr-preview-banner-text { -webkit-flex: 1; flex: 1; min-width: 0; }
.cr-preview-banner-title { font-family: 'Outfit', sans-serif; font-size: 0.82rem; font-weight: 700; color: #fff; }
.cr-preview-banner-sub { font-family: 'Outfit', sans-serif; font-size: 0.7rem; color: rgba(255,255,255,0.5); margin-top: 1px; }
@media (max-width: 480px) { .cr-preview-banner-sub { display: none; } }
.cr-preview-banner-actions { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; gap: 0.45rem; -webkit-flex-shrink: 0; flex-shrink: 0; }
.cr-preview-btn-login { display: -webkit-inline-flex; display: inline-flex; padding: 0.45rem 1rem; background: none; color: #fff; font-family: 'Outfit', sans-serif; font-size: 0.8rem; font-weight: 700; border: 1px solid rgba(255,255,255,0.3); border-radius: 999px; cursor: pointer; text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent; -webkit-transition: border-color 0.15s; transition: border-color 0.15s; }
.cr-preview-btn-login:hover { border-color: #fff; }
.cr-preview-btn-signup { display: -webkit-inline-flex; display: inline-flex; padding: 0.48rem 1.2rem; background: #fff; color: #080808; font-family: 'Outfit', sans-serif; font-size: 0.8rem; font-weight: 800; border: none; border-radius: 999px; cursor: pointer; text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent; -webkit-transition: background 0.15s; transition: background 0.15s; }
.cr-preview-btn-signup:hover { background: rgba(255,255,255,0.88); }
.cr-preview-banner-dismiss { width: 24px; height: 24px; border-radius: 50%; border: none; background: none; color: rgba(255,255,255,0.45); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; cursor: pointer; -webkit-flex-shrink: 0; flex-shrink: 0; -webkit-transition: color 0.15s; transition: color 0.15s; font-family: inherit; -webkit-tap-highlight-color: transparent; }
.cr-preview-banner-dismiss:hover { color: #fff; }

/* ══════════════════════════════════════════════
   UPDATE BANNER
══════════════════════════════════════════════ */
.update-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: linear-gradient(90deg, #1a1025 0%, #160e20 100%);
  border-bottom: 2px solid #8B5CF6;
  -webkit-transform: translateY(-100%); transform: translateY(-100%);
  -webkit-transition: -webkit-transform 0.4s cubic-bezier(0.23,1,0.32,1);
  transition: transform 0.4s cubic-bezier(0.23,1,0.32,1);
  box-shadow: 0 4px 24px rgba(139,92,246,0.2);
}
.update-banner.visible { -webkit-transform: translateY(0); transform: translateY(0); }
.update-banner-inner { padding: 0.7rem 1.5rem; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; gap: 0.75rem; }
.update-banner-icon { font-size: 1.1rem; -webkit-flex-shrink: 0; flex-shrink: 0; }
.update-banner-msg { -webkit-flex: 1; flex: 1; font-family: 'Outfit', sans-serif; font-size: 0.85rem; font-weight: 500; color: rgba(255,255,255,0.85); }
.update-banner-btn { -webkit-flex-shrink: 0; flex-shrink: 0; padding: 0.4rem 1rem; background: #8B5CF6; color: #fff; font-size: 0.8rem; font-weight: 700; border-radius: 999px; border: none; cursor: pointer; font-family: inherit; white-space: nowrap; -webkit-transition: opacity 0.15s; transition: opacity 0.15s; }
.update-banner-btn:hover { opacity: 0.88; }
.update-banner-dismiss { -webkit-flex-shrink: 0; flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; font-size: 0.7rem; color: rgba(255,255,255,0.45); background: rgba(255,255,255,0.07); border: none; cursor: pointer; font-family: inherit; -webkit-transition: background 0.15s, color 0.15s; transition: background 0.15s, color 0.15s; }
.update-banner-dismiss:hover { background: rgba(255,255,255,0.15); color: #fff; }