/* ============================================================
   SLEEP LIBRARY — STYLESHEET
   ============================================================
   TABLE OF CONTENTS:
   1. CSS Variables & Base
   2. Mobile Header (hamburger menu)
   3. Login Screen
   4. Main App Layout
   5. Sidebar
   6. Main Content
   7. Story Cards
   8. Audio Player
   9. Empty State
   10. Utility & Animations
   11. Responsive Design (Mobile)
   ============================================================ */

/* ───────────────────────────────────────────────────────────
   1. CSS VARIABLES & BASE
   ─────────────────────────────────────────────────────────── */
:root {
  /* Colors — Navy/Gold Theme */
  --navy: #080f1a;
  --navy-2: #0d1825;
  --navy-3: #111f30;
  --navy-4: #162438;
  --indigo: #1a2d4a;
  --gold: #c9a84c;
  --gold-light: #e8c97a;
  --gold-dim: rgba(201, 168, 76, 0.15);
  --gold-border: rgba(201, 168, 76, 0.25);
  --cream: #f5f0e8;
  --cream-dim: rgba(245, 240, 232, 0.7);
  --cream-muted: rgba(245, 240, 232, 0.4);
  --white: #fdfaf5;
  --red: #c0392b;

  /* Layout */
  --sidebar-w: 240px;
  --player-h: 90px;
  --header-h: 60px;

  /* Luxe: Fluid Typography Scale */
  --text-xs: clamp(0.65rem, 0.6rem + 0.25vw, 0.7rem);
  --text-sm: clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.95rem, 0.9rem + 0.25vw, 1.05rem);
  --text-lg: clamp(1.05rem, 0.95rem + 0.5vw, 1.2rem);
  --text-xl: clamp(1.3rem, 1.1rem + 1vw, 1.6rem);
  --text-2xl: clamp(1.6rem, 1.3rem + 1.5vw, 2rem);

  /* Luxe: Spacing Rhythm */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Luxe: Transitions */
  --ease-luxe: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-base: 0.3s var(--ease-luxe);
  --transition-slow: 0.5s var(--ease-luxe);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--navy);
  color: var(--cream);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: var(--text-base);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Stars Background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 10%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 60%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 70%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 90%, rgba(255,255,255,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 45%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 15%, rgba(255,255,255,0.2) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ───────────────────────────────────────────────────────────
    2. MOBILE HEADER (Hidden on Desktop)
    ─────────────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  justify-content: flex-start;
  padding-left: 16px;
}

/* Desktop Menu Button */
.desktop-menu-btn {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  background: var(--navy-2);
  border: 1px solid var(--gold-border);
  color: var(--cream);
  width: 44px;
  height: 44px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.4rem;
  z-index: 150;
  transition: var(--transition-base);
}

.desktop-menu-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.desktop-menu-btn.highlight {
  animation: menuHighlight 2s ease-in-out;
}

@keyframes menuHighlight {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 transparent;
  }
  10% {
    transform: scale(1.1);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 20px rgba(201, 168, 76, 0.4);
  }
  20% {
    transform: scale(1);
    border-color: var(--gold-border);
    color: var(--cream);
  }
  30% {
    transform: scale(1.05);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 15px rgba(201, 168, 76, 0.3);
  }
  50% {
    transform: scale(1);
    border-color: var(--gold-border);
    color: var(--cream);
  }
  70% {
    transform: scale(1.03);
    border-color: var(--gold-light);
    color: var(--gold-light);
    box-shadow: 0 0 10px rgba(201, 168, 76, 0.2);
  }
  90% {
    transform: scale(1);
    border-color: var(--gold-border);
    color: var(--cream);
  }
}

@media (min-width: 768px) {
  .desktop-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .desktop-menu-btn.sidebar-open {
    left: calc(var(--sidebar-w) + 20px);
    transition: left var(--transition-slow);
  }
}
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  border-bottom: 1px solid var(--gold-border);
  z-index: 300;
  padding: 0 var(--space-md);
  align-items: center;
  justify-content: space-between;
}

.mobile-header-brand {
  font-family: 'Cinzel', serif;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hamburger-btn {
  background: none;
  border: 1px solid var(--gold-border);
  color: var(--cream);
  width: 44px;
  height: 44px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: var(--transition-base);
}

.hamburger-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 240;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ───────────────────────────────────────────────────────────
   3. LOGIN SCREEN
   ─────────────────────────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  flex-direction: column;
  padding: var(--space-md);
}

.login-glow {
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(201,168,76,0.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.login-box {
  position: relative;
  width: min(380px, 100%);
  padding: var(--space-2xl) var(--space-xl);
  border: 1px solid var(--gold-border);
  background: linear-gradient(160deg, var(--navy-2), var(--navy-3));
  text-align: center;
  box-shadow:
    0 0 60px rgba(201, 168, 76, 0.05),
    0 20px 40px rgba(0, 0, 0, 0.3);
}

.login-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.login-moon {
  font-size: 2.4rem;
  margin-bottom: var(--space-md);
  display: block;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.login-title {
  font-family: 'Cinzel', serif;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.12em;
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
}

.login-subtitle {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: var(--text-base);
  color: var(--cream-muted);
  margin-bottom: var(--space-xl);
  letter-spacing: 0.04em;
}

.login-label {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-sm);
  display: block;
  text-align: left;
}

.login-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--gold-border);
  color: var(--cream);
  font-family: 'Crimson Pro', serif;
  font-size: var(--text-base);
  padding: 14px var(--space-md);
  outline: none;
  transition: var(--transition-base);
  margin-bottom: var(--space-xl);
  letter-spacing: 0.08em;
  border-radius: 4px;
}

.login-input:focus {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.06);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.1);
}

.login-btn {
  width: 100%;
  background: var(--gold);
  color: var(--navy);
  border: none;
  font-family: 'Cinzel', serif;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 14px;
  cursor: pointer;
  transition: var(--transition-base);
  border-radius: 4px;
}

.login-btn:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
}

.login-btn:active {
  transform: scale(0.99) translateY(0);
}

.login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  margin-top: var(--space-md);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: #e88080;
  opacity: 0;
  transition: var(--transition-base);
  letter-spacing: 0.04em;
  min-height: 1.2em;
}

.login-error.visible {
  opacity: 1;
}

.login-footer {
  margin-top: var(--space-xl);
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--cream-muted);
}

/* ───────────────────────────────────────────────────────────
   4. MAIN APP LAYOUT
   ─────────────────────────────────────────────────────────── */
#app {
  display: none;
  min-height: 100vh;
  padding-bottom: var(--player-h);
}

#app.visible {
  display: flex;
}

/* ───────────────────────────────────────────────────────────
   5. SIDEBAR
   ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--navy-2) 0%, var(--navy) 100%);
  border-right: 1px solid var(--gold-border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: var(--player-h);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  /* Mobile: hidden by default, slide in from left */
  transform: translateX(-100%);
  transition: transform var(--transition-slow);
}

.sidebar.open {
  transform: translateX(0);
}

/* Desktop: Sidebar can be collapsed */
@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  .main {
    margin-left: var(--sidebar-w);
    transition: margin-left var(--transition-slow);
  }

  .main.sidebar-collapsed {
    margin-left: 0;
  }
}

.sidebar-logo {
  padding: var(--space-xl) var(--space-lg);
  border-bottom: 1px solid var(--gold-border);
}

.sidebar-brand {
  font-family: 'Cinzel', serif;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.4;
}

.sidebar-tagline {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: var(--text-xs);
  color: var(--cream-muted);
  margin-top: 2px;
}

.sidebar-section {
  padding: var(--space-lg) var(--space-md) var(--space-sm);
}

.sidebar-section:first-of-type {
  padding-top: var(--space-xl);
}

.sidebar-section-label {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream-muted);
  padding: 0 var(--space-sm);
  margin-bottom: var(--space-sm);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-base);
  font-family: 'Crimson Pro', serif;
  font-size: var(--text-base);
  color: var(--cream-dim);
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.sidebar-item:hover {
  background: var(--gold-dim);
  color: var(--cream);
}

.sidebar-item.active {
  background: var(--gold-dim);
  border-color: var(--gold-border);
  color: var(--gold-light);
}

.sidebar-item .icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.sidebar-bottom {
  margin-top: auto;
  padding: var(--space-md);
  border-top: 1px solid var(--gold-border);
}

.logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--gold-border);
  color: var(--cream-muted);
  font-family: 'Crimson Pro', serif;
  font-size: var(--text-sm);
  padding: 10px;
  cursor: pointer;
  transition: var(--transition-base);
  border-radius: 4px;
}

.logout-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* Mobile: sidebar adjustments */
@media (max-width: 767px) {
  .sidebar {
    top: var(--header-h);
    width: 280px;
    bottom: var(--player-h);
  }
}

/* ───────────────────────────────────────────────────────────
   6. MAIN CONTENT
   ─────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: var(--space-2xl) var(--space-xl);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

@media (max-width: 767px) {
  .main {
    margin-left: 0;
    padding: var(--space-xl) var(--space-md);
    padding-top: calc(var(--header-h) + var(--space-lg));
  }
}

.main-header {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--gold-border);
}

@media (min-width: 768px) {
  .main-header {
    padding-left: 80px;
  }
}

@media (max-width: 767px) {
  .main-header {
    padding-top: 0;
  }
}

.main-greeting {
  font-family: 'Cinzel', serif;
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
  margin-bottom: var(--space-sm);
}

.main-subtitle {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--cream-muted);
}

.section-title {
  font-family: 'Cinzel', serif;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-xl);
  display: flex;
  align-items: center;
  gap: 12px;
}

@media (min-width: 768px) {
  .section-title {
    padding-left: 64px;
  }
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gold-border);
}

/* ───────────────────────────────────────────────────────────
   7. STORY CARDS
   ─────────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-3xl);
}

@media (min-width: 768px) {
  .cards-grid {
    padding-left: 64px;
    padding-right: var(--space-xl);
  }
}

.story-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(
      ellipse at 30% 0%,
      rgba(201, 168, 76, 0.04) 0%,
      transparent 50%
    ),
    linear-gradient(160deg, var(--navy-3) 0%, var(--navy-4) 100%);
  border: 1px solid var(--gold-border);
  padding: var(--space-xl);
  cursor: pointer;
  transition:
    border-color var(--transition-base),
    transform var(--transition-base),
    box-shadow var(--transition-base);
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(201, 168, 76, 0.1),
    0 4px 16px rgba(0, 0, 0, 0.15);
}

.story-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 168, 76, 0.3), transparent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.story-card:hover {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow:
    0 12px 40px rgba(201, 168, 76, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(201, 168, 76, 0.15);
}

.story-card:hover::before {
  opacity: 1;
}

.story-card.playing {
  border-color: var(--gold);
  background:
    linear-gradient(160deg, var(--indigo) 0%, var(--navy-4) 100%),
    radial-gradient(ellipse at 30% 0%, rgba(201, 168, 76, 0.06) 0%, transparent 50%);
}

.story-card.playing::before {
  opacity: 1;
}

/* Luxe: Staggered entrance animation */
.story-card {
  opacity: 0;
  transform: translateY(20px);
  animation: cardReveal 0.5s var(--ease-luxe) forwards;
}

@keyframes cardReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.story-card:nth-child(1) { animation-delay: 0ms; }
.story-card:nth-child(2) { animation-delay: 75ms; }
.story-card:nth-child(3) { animation-delay: 150ms; }
.story-card:nth-child(4) { animation-delay: 225ms; }
.story-card:nth-child(5) { animation-delay: 300ms; }
.story-card:nth-child(6) { animation-delay: 375ms; }
.story-card:nth-child(n+7) { animation-delay: 450ms; }

.card-mood {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-sm);
  opacity: 0.8;
}

.card-title {
  font-family: 'Cinzel', serif;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--cream);
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.card-desc {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--cream-muted);
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.card-duration {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--cream-muted);
  letter-spacing: 0.06em;
}

.card-type {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--gold-border);
  color: var(--gold);
  border-radius: 3px;
}

.card-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: auto;
}

.btn-play {
  flex: 1;
  background: var(--gold);
  color: var(--navy);
  border: none;
  font-family: 'Cinzel', serif;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 12px 14px;
  cursor: pointer;
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 4px;
}

.btn-play:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
}

.btn-play:active {
  transform: scale(0.98) translateY(0);
}

.btn-download {
  background: transparent;
  border: 1px solid var(--gold-border);
  color: var(--cream-dim);
  padding: 10px 12px;
  cursor: pointer;
  transition: var(--transition-base);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  text-decoration: none;
  border-radius: 4px;
  min-width: 44px;
  justify-content: center;
}

.btn-download:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.now-playing-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--gold);
  color: var(--navy);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 3px;
  animation: subtle-pulse 2s ease-in-out infinite;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: var(--space-sm);
}

.new-badge {
  background: var(--gold);
  color: var(--navy);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 3px;
  flex-shrink: 0;
}

.story-card.new-story {
  background:
    radial-gradient(
      ellipse at 70% 0%,
      rgba(201, 168, 76, 0.12) 0%,
      transparent 50%
    ),
    linear-gradient(200deg, #f5f0e8 0%, #e8e0d0 100%);
  border-color: var(--gold);
}

.story-card.new-story .card-mood {
  color: #8b6914;
}

.story-card.new-story .card-title {
  color: var(--navy);
}

.story-card.new-story .card-desc {
  color: #5a4a2a;
}

.story-card.new-story .card-duration {
  color: #5a4a2a;
}

.story-card.new-story .card-type {
  color: #8b6914;
  background: rgba(201, 168, 76, 0.1);
}

.story-card.new-story .btn-download {
  border-color: #8b6914;
  color: #5a4a2a;
}

.story-card.new-story .btn-download:hover {
  border-color: var(--navy);
  color: var(--navy);
}

.story-card.new-story::before {
  opacity: 1;
}

.story-card.new-story::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}

@keyframes subtle-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* ───────────────────────────────────────────────────────────
   8. AUDIO PLAYER
   ─────────────────────────────────────────────────────────── */
#player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--player-h);
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  border-top: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-xl);
  gap: var(--space-lg);
  z-index: 200;
}

@media (max-width: 600px) {
  #player {
    padding: 0 var(--space-md);
    gap: var(--space-sm);
  }
}

.player-info {
  width: 220px;
  min-width: 160px;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .player-info {
    width: auto;
    flex: 1;
    min-width: 0;
  }
}

.player-track {
  font-family: 'Cinzel', serif;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.player-type {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--cream-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .player-controls {
    gap: 8px;
  }
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--cream-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 6px;
  transition: var(--transition-base);
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ctrl-btn:hover {
  color: var(--cream);
}

.ctrl-btn.play-pause {
  background: var(--gold);
  color: var(--navy);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-base);
}

.ctrl-btn.play-pause:hover {
  background: var(--gold-light);
  transform: scale(1.05);
}

.ctrl-btn.play-pause:active {
  transform: scale(0.95);
}

.player-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

@media (max-width: 500px) {
  .player-progress {
    display: none;
  }
}

.time-label {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--cream-muted);
  letter-spacing: 0.04em;
  width: 38px;
  flex-shrink: 0;
  text-align: center;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.1);
  cursor: pointer;
  position: relative;
  border-radius: 3px;
  transition: height var(--transition-base);
}

.progress-bar:hover {
  height: 6px;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--gold);
  border-radius: 3px;
  transition: width 0.1s linear;
  pointer-events: none;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: var(--gold-light);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.progress-bar:hover .progress-thumb {
  opacity: 1;
}

.player-volume {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .player-volume {
    display: none;
  }
}

.volume-icon {
  color: var(--cream-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-base);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.volume-icon:hover {
  color: var(--cream);
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--transition-base);
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* ───────────────────────────────────────────────────────────
   9. EMPTY STATE
   ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-md);
  color: var(--cream-muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state p {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: var(--text-lg);
  line-height: 1.6;
}

/* ───────────────────────────────────────────────────────────
   10. UTILITY & ANIMATIONS
   ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--navy);
}

::-webkit-scrollbar-thumb {
  background: var(--gold-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

.fade-in {
  animation: fadeIn 0.5s var(--ease-luxe) forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-banner {
  background:
    linear-gradient(135deg, var(--indigo), var(--navy-3)),
    radial-gradient(ellipse at 80% 50%, rgba(201, 168, 76, 0.05) 0%, transparent 50%);
  border: 1px solid var(--gold-border);
  padding: var(--space-xl);
  margin-bottom: var(--space-2xl);
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

@media (min-width: 768px) {
  .welcome-banner {
    margin-left: 64px;
    margin-right: var(--space-xl);
  }
}

.welcome-banner::after {
  content: '🌙';
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 4rem;
  opacity: 0.08;
}

@media (max-width: 600px) {
  .welcome-banner::after {
    display: none;
  }
}

.welcome-banner h2 {
  font-family: 'Cinzel', serif;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
}

.welcome-banner p {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: var(--text-base);
  color: var(--cream-dim);
  line-height: 1.6;
  max-width: 500px;
}

.keyboard-hint {
  font-family: 'Inter', sans-serif !important;
  font-style: normal !important;
  font-size: var(--text-xs) !important;
  color: var(--cream-muted) !important;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--gold-border);
}

/* ───────────────────────────────────────────────────────────
   11. RESPONSIVE DESIGN (Mobile)
   ─────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Show mobile header, hide desktop sidebar */
  .mobile-header {
    display: flex;
  }

  .sidebar {
    z-index: 250;
  }

  /* Adjust main content for mobile header */
  #app.visible .main {
    padding-top: calc(var(--header-h) + var(--space-lg));
  }

  /* Cards full width on mobile */
  .cards-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .story-card {
    padding: var(--space-lg);
  }

  /* Hide volume on very small screens */
  .player-info {
    width: auto;
    flex: 1;
  }

  .player-track {
    font-size: var(--text-xs);
  }

  .player-type {
    display: none;
  }
}

@media (max-width: 400px) {
  .main {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }

  .login-box {
    padding: var(--space-xl) var(--space-lg);
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .ctrl-btn,
  .hamburger-btn,
  .btn-download,
  .sidebar-item {
    min-height: 44px;
    min-width: 44px;
  }

  .progress-bar {
    height: 8px;
  }
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

/* Loading and error states */
.loading, .error {
  text-align: center;
  padding: 20px;
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--cream-muted);
  grid-column: 1 / -1;
}

.loading {
  color: var(--gold);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.error {
  color: #e88080;
}

/* ═══════════════════════════════════════════════════════════
   ENHANCED ERROR TOAST
   ═══════════════════════════════════════════════════════════ */

.enhanced-error {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #c0392b;
  color: white;
  padding: 12px 20px;
  border-radius: 4px;
  z-index: 10000;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  max-width: 360px;
  line-height: 1.4;
}

.enhanced-error.visible {
  opacity: 1;
  pointer-events: auto;
}
}