/* ==========================================================================
   CapbairPlus Audio Hub - Modern Dark Luxury Design System
   Matches Obsidian EbookLibrary Standards:
   - Fixed Deep Midnight Slate (#020617)
   - Warm Amber Gold (#e0a458)
   - 3D Physical Cards: Vinyl Sleeves, Audiobook Slipcases, Cassettes
   - High-Fidelity Persistent Bottom Audio Player
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #020617;
  --bg-soft: #070d1e;
  --panel: #0a0f1f;
  --panel-2: #0e1526;
  --panel-3: #131c31;
  --panel-hover: #16223b;
  --border: #1e2740;
  --border-strong: #2c3654;
  --text: #eef1fa;
  --text-dim: #8792ab;
  --text-muted: #5e6982;

  --accent: #e0a458;
  --accent-dim: #b9823f;
  --accent-tint: #f0c98a;
  --accent-glow: rgba(224, 164, 88, 0.22);

  --music: #38bdf8;
  --music-bg: rgba(56, 189, 248, 0.12);
  --audiobook: #f59e0b;
  --audiobook-bg: rgba(245, 158, 11, 0.12);
  --podcast: #10b981;
  --podcast-bg: rgba(16, 185, 129, 0.12);

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;

  --font-head: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Dynamic Glow */
#ambient-dynamic-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  transition: background-image 1.2s ease;
  background: 
    radial-gradient(ellipse 65% 50% at 50% -10%, rgba(224, 164, 88, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 85% 20%, rgba(56, 189, 248, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 15% 60%, rgba(245, 158, 11, 0.04) 0%, transparent 60%);
}

#top-nav-loader {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-tint));
  z-index: 9999;
  transition: width 0.3s ease;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-tint);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 120px;
}

/* ==========================================================================
   Global Header & Navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-logo svg {
  color: var(--accent);
}

.brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.desktop-nav .nav-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 6px;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--panel-2);
}

.nav-links a.active {
  color: var(--accent);
  font-weight: 600;
}

.header-search {
  flex: 1;
  max-width: 440px;
}

.header-search form {
  position: relative;
  display: flex;
  align-items: center;
}

.header-search svg {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.header-search input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 42px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ==========================================================================
   Hero Showcase Banner
   ========================================================================== */
.hero-showcase {
  background: linear-gradient(135deg, rgba(14, 21, 38, 0.8) 0%, rgba(10, 15, 31, 0.95) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
}

.hero-showcase::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--panel-3);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 16px;
}

.hero-title {
  font-family: var(--font-head);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 14px;
  color: #fff;
}

.hero-desc {
  font-size: 15px;
  color: var(--text-dim);
  max-width: 600px;
  margin: 0 0 24px;
}

.hero-stats {
  display: flex;
  gap: 28px;
  margin-top: 20px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* ==========================================================================
   Section Headers & Category Pills
   ========================================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 36px 0 20px;
}

.section-title {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title svg {
  color: var(--accent);
}

.badge-pill {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-music { background: var(--music-bg); color: var(--music); }
.badge-audiobook { background: var(--audiobook-bg); color: var(--audiobook); }
.badge-podcast { background: var(--podcast-bg); color: var(--podcast); }

/* ==========================================================================
   Card Grid & 3D Skeuomorphic Vinyl/Slipcase Cards
   ========================================================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}

.audio-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  position: relative;
}

.audio-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-strong);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

/* 3D Vinyl Sleeve Showcase */
.vinyl-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  perspective: 800px;
  cursor: pointer;
  margin-bottom: 14px;
}

.vinyl-disc {
  position: absolute;
  top: 5%;
  right: 5%;
  width: 90%;
  height: 90%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #181818 0%, #080808 60%, #000 100%);
  box-shadow: inset 0 0 0 2px #222, inset 0 0 0 16px #080808, inset 0 0 0 18px #222, inset 0 0 0 34px #080808, inset 0 0 0 36px #222, 0 8px 18px rgba(0,0,0,0.7);
  z-index: 1;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.vinyl-label {
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vinyl-center-hole {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #000;
}

.vinyl-sleeve {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
  background: var(--panel-2);
  transition: transform 0.4s ease;
}

.vinyl-sleeve img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vinyl-container:hover .vinyl-disc {
  transform: translateX(35%) rotate(45deg);
}

.vinyl-container:hover .vinyl-sleeve {
  transform: rotateY(-8deg);
}

.card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 15px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

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

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   Persistent Bottom Audio Player Bar
   ========================================================================== */
#global-audio-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 76px;
  background: rgba(2, 6, 23, 0.94);
  backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 20px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#global-audio-player.is-active {
  transform: translateY(0);
}

.player-track-info {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
  max-width: 320px;
}

.player-cover-box {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.player-cover-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.is-spinning {
  animation: spin 12s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.player-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-artist {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Central Controls & Seek Bar */
.player-controls {
  flex: 1;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.player-buttons {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-ctrl {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.btn-ctrl:hover {
  color: #fff;
  background: var(--panel-hover);
}

.btn-play-prime {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #020617;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 0.15s ease, background 0.2s ease;
}

.btn-play-prime:hover {
  transform: scale(1.08);
  background: var(--accent-tint);
}

.player-progress-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.seek-track-wrapper {
  position: relative;
  flex: 1;
  height: 5px;
  background: var(--panel-3);
  border-radius: 3px;
  cursor: pointer;
}

.seek-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  pointer-events: none;
}

.seek-input {
  position: absolute;
  top: -6px;
  left: 0;
  width: 100%;
  height: 17px;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

/* Utilities (Speed, Volume) */
.player-utilities {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 220px;
  justify-content: flex-end;
}

.btn-speed {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.volume-slider {
  width: 80px;
  accent-color: var(--accent);
  height: 4px;
}

/* Responsive */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .player-utilities {
    display: none;
  }
  .player-track-info {
    min-width: 140px;
  }
}

/* ===== Three-Column App Layout ===== */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr 240px;
  gap: 0;
  max-width: 1600px;
  margin: 0 auto;
  min-height: calc(100vh - 60px - 84px);
  align-items: start;
}

.app-main {
  padding: 32px 24px;
  min-width: 0;
}

/* Rails */
.rail {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px - 84px);
  overflow-y: auto;
  padding: 16px 0;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  background: var(--panel);
}

.rail-right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.rail::-webkit-scrollbar { width: 5px; }
.rail::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.rail-section { padding: 0 0 16px; }
.rail-section + .rail-section { border-top: 1px solid var(--border); padding-top: 16px; }

.rail-title {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 16px 8px;
}

.rail-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.rail-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.rail-link:hover, .rail-link.active {
  background: var(--panel-2);
  color: var(--text);
}

.rail-link.active { color: var(--accent); font-weight: 600; }

/* Queue list in left rail */
.rail-queue-list { padding: 0 8px; display: flex; flex-direction: column; gap: 2px; }

.rail-queue-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s;
}

.rail-queue-item:hover { background: var(--panel-2); color: var(--text); }
.rail-queue-item.playing { color: var(--accent); }

.rail-queue-item .q-num {
  flex: none;
  width: 16px;
  font-size: 10px;
  text-align: center;
  color: var(--text-muted);
}

.rail-queue-item .q-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-clear-btn {
  margin: 8px;
  width: calc(100% - 16px);
  padding: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.rail-clear-btn:hover { background: var(--panel-3); color: var(--text); }

/* Favorites in right rail */
.rail-fav-list { padding: 0 8px; display: flex; flex-direction: column; gap: 4px; }

.rail-fav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13px;
  transition: background 0.15s;
}

.rail-fav-item:hover { background: var(--panel-2); color: var(--text); }

.rail-fav-item img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  flex: none;
}

.rail-fav-item .fav-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.rail-fav-item .fav-artist {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-empty { padding: 8px 16px; font-size: 12px; color: var(--text-muted); }

/* Multi-select checkboxes on track rows */
.track-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.multi-select-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.multi-select-bar.visible { display: flex; }

.multi-select-bar .ms-count { color: var(--accent); font-weight: 600; }

.btn-fav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  transition: color 0.15s, transform 0.15s;
  line-height: 1;
}

.btn-fav:hover { color: #f43f5e; transform: scale(1.15); }
.btn-fav.favorited { color: #f43f5e; }

/* Responsive: hide rails on small screens */
@media (max-width: 1100px) {
  .app-layout { grid-template-columns: 1fr; }
  .rail { display: none; }
}

@media (max-width: 1300px) {
  .app-layout { grid-template-columns: 200px 1fr; }
  .rail-right { display: none; }
}

.rail-search-box { padding: 0 8px 8px; }
.rail-search-input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  box-sizing: border-box;
}
.rail-search-input:focus { border-color: var(--accent-dim); }

.rail-dir-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  gap: 6px;
  overflow: hidden;
}
.rail-dir-item:hover, .rail-dir-item.active {
  background: var(--panel-2);
  color: var(--text);
}
.rail-dir-item.active { color: var(--accent); }
.rail-dir-item .dir-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-dir-item .dir-count {
  flex: none;
  font-size: 10px;
  background: var(--panel-3);
  color: var(--text-muted);
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 20px;
  text-align: center;
}