/* Rhapsody Theme - Kangaroo-inspired podcast app.
   Primary: deep teal/ocean. Accent: warm orange/sunset.
   Cream backgrounds, subtle gray text. Hop animations, mini-player. Dark mode supported.
   Icons: Font Awesome 6 Free (solid) — include via app’s main CSS (e.g. tailwind/application.css) so @import is first. */

/* 1. Palette and theme aliases */
:root {
  /* Teal / ocean blue scale (primary) */
  --color-rhapsody-teal-50: #e6f4f4;
  --color-rhapsody-teal-100: #b3e0e0;
  --color-rhapsody-teal-200: #80cccb;
  --color-rhapsody-teal-300: #4db8b7;
  --color-rhapsody-teal-400: #26a3a2;
  --color-rhapsody-teal-500: #006d77;
  --color-rhapsody-teal-600: #005a63;
  --color-rhapsody-teal-700: #00474f;
  --color-rhapsody-teal-800: #00353b;
  --color-rhapsody-teal-900: #002327;

  /* Warm orange / sunset (accent) */
  --color-rhapsody-orange-50: #fff8ed;
  --color-rhapsody-orange-100: #ffecd1;
  --color-rhapsody-orange-200: #ffd9a3;
  --color-rhapsody-orange-300: #ffc675;
  --color-rhapsody-orange-400: #ffb347;
  --color-rhapsody-orange-500: #ff9f1c;
  --color-rhapsody-orange-600: #e68a00;
  --color-rhapsody-orange-700: #cc7700;
  --color-rhapsody-orange-800: #996000;
  --color-rhapsody-orange-900: #664000;

  /* Neutrals: cream / off-white, subtle gray text */
  --color-rhapsody-cream-50: #fefdfb;
  --color-rhapsody-cream-100: #faf8f3;
  --color-rhapsody-cream-200: #f5f1e8;
  --color-rhapsody-cream-300: #ebe5d9;
  --color-rhapsody-gray-400: #9ca3af;
  --color-rhapsody-gray-500: #6b7280;
  --color-rhapsody-gray-600: #4b5563;
  --color-rhapsody-gray-700: #374151;
  --color-rhapsody-gray-800: #1f2937;
  --color-rhapsody-gray-900: #111827;

  /* Semantic theme aliases (light mode) */
  --color-rhapsody-primary: var(--color-rhapsody-teal-500);
  --color-rhapsody-primary-dark: var(--color-rhapsody-teal-600);
  --color-rhapsody-primary-light: var(--color-rhapsody-teal-400);
  --color-rhapsody-secondary: var(--color-rhapsody-orange-500);
  --color-rhapsody-accent: var(--color-rhapsody-orange-500);
  --color-rhapsody-background: var(--color-rhapsody-cream-100);
  --color-rhapsody-surface: var(--color-rhapsody-cream-50);
  --color-rhapsody-text: var(--color-rhapsody-gray-800);
  --color-rhapsody-text-muted: var(--color-rhapsody-gray-600);
  --color-rhapsody-border: var(--color-rhapsody-cream-300);

  /* Responsive breakpoint (match Tailwind md) */
  --rhapsody-breakpoint-md: 768px;

  /* Motion & shape */
  --rhapsody-radius-sm: 0.375rem;
  --rhapsody-radius-md: 0.75rem;
  --rhapsody-radius-lg: 1rem;
  --rhapsody-radius-xl: 1.25rem;
  --rhapsody-radius-2xl: 1.5rem;
  --rhapsody-radius-full: 9999px;
  --rhapsody-transition: 0.2s ease;
  --rhapsody-transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Base component styles */
.rhapsody-card {
  background-color: var(--color-rhapsody-surface);
  border-radius: var(--rhapsody-radius-lg);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.06);
  border: 1px solid var(--color-rhapsody-border);
  transition: box-shadow var(--rhapsody-transition), transform var(--rhapsody-transition);
}

.rhapsody-card-hover:hover {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
}

/* Row (media list item: play + body + actions) */
.rhapsody-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  min-width: 0;
}

.rhapsody-row__content {
  flex: 1 1 0;
  min-width: 0;
}

.rhapsody-row__title {
  font-weight: 500;
  color: var(--color-rhapsody-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.rhapsody-row__meta {
  font-size: 0.875rem;
  color: var(--color-rhapsody-text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.rhapsody-row__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .rhapsody-row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .rhapsody-row__play {
    flex-shrink: 0;
    align-self: flex-start;
  }

  .rhapsody-row__content {
    flex: 1 1 0;
    min-width: 0;
  }

  .rhapsody-row__title {
    white-space: normal;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
  }

  .rhapsody-row__meta {
    margin-top: 0.375rem;
  }

  .rhapsody-row__actions {
    flex-basis: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding-top: 0.25rem;
    border-top: 1px solid var(--color-rhapsody-border);
  }
}

/* Listened badge (row, playlists) */
.rhapsody-listened-badge,
.listened-badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  background: var(--color-rhapsody-surface);
  color: var(--color-rhapsody-text-muted);
  border: 1px solid var(--color-rhapsody-border);
}

.rhapsody-listened-badge--listened,
.listened-badge.listened-badge--listened {
  background: var(--color-rhapsody-primary);
  color: #fff;
  border-color: var(--color-rhapsody-primary);
}

.rhapsody-button-primary {
  background-color: var(--color-rhapsody-primary);
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--rhapsody-radius-md);
  transition: background-color var(--rhapsody-transition), transform var(--rhapsody-transition);
  border: none;
  cursor: pointer;
}

.rhapsody-button-primary:hover {
  background-color: var(--color-rhapsody-primary-dark);
}

.rhapsody-button-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-rhapsody-surface), 0 0 0 4px var(--color-rhapsody-primary);
}

.rhapsody-button-accent {
  background-color: var(--color-rhapsody-accent);
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--rhapsody-radius-md);
  transition: background-color var(--rhapsody-transition), transform var(--rhapsody-transition);
  border: none;
  cursor: pointer;
}

.rhapsody-button-accent:hover {
  background-color: var(--color-rhapsody-orange-600);
}

.rhapsody-button-outline {
  border: 2px solid var(--color-rhapsody-primary);
  color: var(--color-rhapsody-primary);
  background-color: transparent;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--rhapsody-radius-md);
  transition: background-color var(--rhapsody-transition), color var(--rhapsody-transition);
  cursor: pointer;
}

.rhapsody-button-outline:hover {
  background-color: var(--color-rhapsody-teal-100);
}

.rhapsody-link {
  color: var(--color-rhapsody-primary);
  text-decoration: none;
  transition: color var(--rhapsody-transition);
}

.rhapsody-link:hover {
  color: var(--color-rhapsody-primary-dark);
  text-decoration: underline;
}

.rhapsody-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: var(--rhapsody-radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1rem;
}

.rhapsody-badge-primary {
  background-color: var(--color-rhapsody-teal-100);
  color: var(--color-rhapsody-primary);
}

.rhapsody-badge-accent {
  background-color: var(--color-rhapsody-orange-100);
  color: var(--color-rhapsody-accent);
}

/* 3. Mini player (persistent bottom bar) */
.rhapsody-mini-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 5rem;
  background-color: var(--color-rhapsody-surface);
  border-top: 1px solid var(--color-rhapsody-border);
  box-shadow: 0 -4px 12px rgb(0 0 0 / 0.06);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  z-index: 50;
  transition: transform var(--rhapsody-transition-smooth);
}

.rhapsody-mini-player-centered {
  left: auto;
  right: auto;
  width: 100%;
  max-width: 56rem;
  margin-left: auto;
  margin-right: auto;
}

.rhapsody-mini-player-hidden {
  display: none !important;
}

.rhapsody-mini-player-collapsed {
  transform: translateY(calc(100% - 3rem));
}

.rhapsody-mini-player-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.rhapsody-mini-player-artwork {
  position: relative;
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  border-radius: var(--rhapsody-radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-rhapsody-border);
}

.rhapsody-mini-player-artwork-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rhapsody-mini-player-artwork-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rhapsody-mini-player-artwork-placeholder {
  font-size: 1.25rem;
  color: var(--color-rhapsody-text-muted);
}

.rhapsody-mini-player-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding-top: 0.125rem;
}

.rhapsody-mini-player-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.rhapsody-mini-player-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-rhapsody-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rhapsody-mini-player-progress-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rhapsody-mini-player-time {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
  flex-shrink: 0;
  color: var(--color-rhapsody-text-muted);
}

.rhapsody-mini-player-progress-track {
  flex: 1;
  min-width: 0;
  height: 0.375rem;
  border-radius: var(--rhapsody-radius-full);
  cursor: pointer;
  background-color: var(--color-rhapsody-border);
  overflow: hidden;
}

.rhapsody-mini-player-progress-fill {
  display: block;
  height: 100%;
  border-radius: var(--rhapsody-radius-full);
  background-color: var(--color-rhapsody-primary);
  transition: width 0.15s ease;
}

.rhapsody-mini-player-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.125rem;
}

.rhapsody-mini-player-btn {
  padding: 0.375rem;
  border-radius: var(--rhapsody-radius-lg);
  background: transparent;
  color: var(--color-rhapsody-text-muted);
  border: none;
  cursor: pointer;
  transition: color var(--rhapsody-transition);
  font: inherit;
  line-height: 1;
}

.rhapsody-mini-player-btn:hover {
  color: var(--color-rhapsody-text);
}

.rhapsody-mini-player-play-btn {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: var(--rhapsody-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background-color: var(--color-rhapsody-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background-color var(--rhapsody-transition);
  font: inherit;
  line-height: 1;
}

.rhapsody-mini-player-play-btn:hover {
  background-color: var(--color-rhapsody-primary-dark);
}

.rhapsody-mini-player-icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* Font Awesome icons in mini player (font-based sizing) */
.rhapsody-mini-player-controls .rhapsody-mini-player-icon.fa-solid {
  width: auto;
  height: auto;
  font-size: 1.25rem;
  color: inherit;
}

.rhapsody-mini-player-controls .rhapsody-mini-player-icon-sm.fa-solid {
  font-size: 1rem;
}

.rhapsody-mini-player-play-btn .fa-solid {
  color: inherit;
}

.rhapsody-mini-player-icon-sm {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.rhapsody-mini-player-volume {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.rhapsody-mini-player-volume-input {
  width: 5rem;
  height: 0.25rem;
  border-radius: var(--rhapsody-radius-full);
  cursor: pointer;
  accent-color: var(--color-rhapsody-primary);
}

.rhapsody-mini-player-speed {
  font-size: 0.75rem;
  font-family: inherit;
  line-height: 1;
  border-radius: var(--rhapsody-radius-sm);
  padding: 0.125rem 0.375rem;
  cursor: pointer;
  color: var(--color-rhapsody-text);
  background-color: var(--color-rhapsody-surface);
  border: 1px solid var(--color-rhapsody-border);
  min-height: 1.5rem;
}

/* 3b. Dropzone (file upload with drag and drop) */
.rhapsody-dropzone {
  cursor: pointer;
}

.rhapsody-dropzone.rhapsody-dropzone-active {
  border-color: var(--color-rhapsody-primary) !important;
  background-color: var(--color-rhapsody-teal-50);
}

.rhapsody-dropzone-icon {
  width: 2rem;
  height: 2rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.rhapsody-dropzone-has-file {
  border-color: var(--color-rhapsody-primary) !important;
  background-color: var(--color-rhapsody-teal-50);
}

.rhapsody-dropzone-selection {
  font-size: 0.8125rem;
  line-height: 1.25;
}

.rhapsody-dropzone-selection-empty {
  visibility: hidden;
}

.rhapsody-dropzone-selection-filled {
  visibility: visible;
  color: var(--color-rhapsody-primary);
  font-weight: 500;
}

/* 4. Layout spacing (content above mini-player) */
.rhapsody-content-with-player {
  padding-bottom: 5.5rem;
}

/* 5. Animations and podcast-specific */
@keyframes rhapsody-hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes rhapsody-bounce-subtle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes rhapsody-progress-hop {
  0%, 100% { transform: translateY(0) scale(1); opacity: 1; }
  50% { transform: translateY(-3px) scale(1.1); opacity: 0.9; }
}

@keyframes rhapsody-pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.rhapsody-animate-hop {
  animation: rhapsody-hop var(--rhapsody-transition-smooth) ease-out;
}

.rhapsody-animate-bounce {
  animation: rhapsody-bounce-subtle 0.4s ease-out;
}

.rhapsody-animate-progress-hop {
  animation: rhapsody-progress-hop 0.6s ease-in-out infinite;
}

.rhapsody-animate-pulse-soft {
  animation: rhapsody-pulse-soft 1.5s ease-in-out infinite;
}

.rhapsody-artwork-card {
  background-color: var(--color-rhapsody-surface);
  border-radius: var(--rhapsody-radius-xl);
  overflow: hidden;
  aspect-ratio: 1;
  transition: transform var(--rhapsody-transition-smooth), box-shadow var(--rhapsody-transition);
}

img.rhapsody-artwork-card {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.rhapsody-artwork-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.08), 0 4px 10px -6px rgb(0 0 0 / 0.05);
}

.rhapsody-artwork-placeholder {
  background-color: var(--color-rhapsody-border);
  color: var(--color-rhapsody-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
}

/* Compact card grid: table on mobile, 3-column grid on desktop */
.rhapsody-card-grid {
  display: none;
  min-width: 0;
  max-width: 100%;
}
@media (min-width: 768px) {
  .rhapsody-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }
}

.rhapsody-card-grid li {
  min-width: 0;
}

/* List component: table on mobile, card grid on desktop */
.rhapsody-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.rhapsody-list__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-rhapsody-text);
}

.rhapsody-list__link {
  text-decoration: none;
  color: inherit;
}

.rhapsody-list__link--block {
  display: block;
  min-width: 0;
}

.rhapsody-list__title-text {
  display: block;
}

/* Generic compact table: leading | main | trailing columns (e.g. image | content | action) */
.rhapsody-table {
  display: table;
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border-spacing: 0;
  border-radius: var(--rhapsody-radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-rhapsody-border);
  background-color: var(--color-rhapsody-surface);
}

@media (min-width: 768px) {
  .rhapsody-table--mobile-only {
    display: none;
  }
}

.rhapsody-table thead {
  display: none;
}

.rhapsody-table tbody tr {
  display: table-row;
  border-bottom: 1px solid var(--color-rhapsody-border);
  background-color: var(--color-rhapsody-surface);
  transition: background-color var(--rhapsody-transition);
}

.rhapsody-table tbody tr:hover {
  background-color: var(--color-rhapsody-cream-200);
}

.rhapsody-table tbody tr:last-child {
  border-bottom: none;
}

.rhapsody-table td {
  display: table-cell;
  vertical-align: middle;
  padding: 0.5rem 0.25rem 0.5rem 0;
}

/* Leading column: fixed width (e.g. artwork/icon) */
.rhapsody-table td:first-child {
  padding-left: 0.5rem;
  padding-right: 0;
  width: 3.5rem;
  min-width: 3.5rem;
  max-width: 3.5rem;
  overflow: hidden;
  vertical-align: middle;
}

.rhapsody-table td:first-child a {
  display: block;
  overflow: hidden;
}

/* Main column: flexible */
.rhapsody-table td:nth-child(2) {
  min-width: 0;
  width: auto;
  overflow: hidden;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

/* Trailing column: fixed width (e.g. action button) */
.rhapsody-table td:last-child {
  padding-right: 0.5rem;
  padding-left: 0.25rem;
  width: 5.5rem;
  min-width: 5.5rem;
  white-space: nowrap;
}

.rhapsody-table .rhapsody-artwork-card {
  width: 3.5rem;
  height: 3.5rem;
  min-width: 3.5rem;
  min-height: 3.5rem;
  aspect-ratio: 1;
  margin: 0;
  display: block;
}

.rhapsody-table img.rhapsody-artwork-card {
  object-fit: cover;
}

.rhapsody-table .rhapsody-artwork-placeholder {
  width: 3.5rem;
  height: 3.5rem;
  min-width: 3.5rem;
  min-height: 3.5rem;
  aspect-ratio: 1;
  font-size: 1.25rem;
}

.rhapsody-table .rhapsody-card-compact-title {
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rhapsody-table .rhapsody-card-compact-meta {
  font-size: 0.75rem;
}

.rhapsody-table .rhapsody-button-outline--compact {
  margin: 0;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  width: auto;
}

.rhapsody-card--compact {
  padding: 0.5rem;
}
@media (min-width: 768px) {
  .rhapsody-card--compact {
    padding: 1rem;
  }
}

.rhapsody-card--compact .rhapsody-artwork-card {
  margin-bottom: 0.375rem;
}
@media (min-width: 768px) {
  .rhapsody-card--compact .rhapsody-artwork-card {
    margin-bottom: 0.75rem;
  }
}

.rhapsody-card--compact .rhapsody-artwork-placeholder {
  font-size: 1.5rem;
}
@media (min-width: 768px) {
  .rhapsody-card--compact .rhapsody-artwork-placeholder {
    font-size: 2.25rem;
  }
}

.rhapsody-card-compact-title {
  font-size: 0.75rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-rhapsody-text);
}
@media (min-width: 768px) {
  .rhapsody-card-compact-title {
    font-size: 1rem;
  }
}

.rhapsody-card-compact-meta {
  font-size: 0.75rem;
  color: var(--color-rhapsody-text-muted);
}
@media (min-width: 768px) {
  .rhapsody-card-compact-meta {
    font-size: 0.875rem;
  }
}

.rhapsody-button-outline--compact {
  margin-top: 0.375rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  width: 100%;
}
@media (min-width: 768px) {
  .rhapsody-button-outline--compact {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
  }
}

.rhapsody-button-play {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--rhapsody-radius-full);
  background-color: var(--color-rhapsody-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--rhapsody-transition), transform var(--rhapsody-transition);
  box-shadow: 0 2px 8px rgb(255 159 28 / 0.35);
}

.rhapsody-button-play:hover {
  transform: scale(1.05);
}

.rhapsody-button-play:active {
  transform: scale(0.95);
}

.rhapsody-progress-track {
  height: 0.25rem;
  background-color: var(--color-rhapsody-border);
  border-radius: var(--rhapsody-radius-full);
  overflow: hidden;
}

.rhapsody-progress-fill {
  height: 100%;
  background-color: var(--color-rhapsody-accent);
  border-radius: var(--rhapsody-radius-full);
  transition: width var(--rhapsody-transition-smooth);
}

.rhapsody-icon-bounce:hover {
  animation: rhapsody-bounce-subtle 0.4s ease-out;
}

.rhapsody-rounded { border-radius: var(--rhapsody-radius-md); }
.rhapsody-rounded-lg { border-radius: var(--rhapsody-radius-lg); }
.rhapsody-rounded-xl { border-radius: var(--rhapsody-radius-xl); }

/* 5b. Modal (theme component) */
.rhapsody-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.rhapsody-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgb(0 0 0 / 0.5);
  transition: opacity var(--rhapsody-transition);
}

.rhapsody-modal-content {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 32rem;
  overflow: hidden;
  border-radius: var(--rhapsody-radius-lg);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  background-color: var(--color-rhapsody-surface);
  color: var(--color-rhapsody-text);
  border: 1px solid var(--color-rhapsody-border);
  transition: transform var(--rhapsody-transition-smooth);
}

.rhapsody-modal-content.rhapsody-modal-sm { max-width: 28rem; }
.rhapsody-modal-content.rhapsody-modal-lg { max-width: 42rem; }
.rhapsody-modal-content.rhapsody-modal-xl { max-width: 56rem; }

.rhapsody-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-rhapsody-border);
}

.rhapsody-modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-rhapsody-text);
}

.rhapsody-modal-body {
  padding: 1rem 1.5rem;
}

.rhapsody-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-rhapsody-border);
}

.rhapsody-modal-close {
  padding: 0.25rem;
  border-radius: var(--rhapsody-radius-sm);
  color: var(--color-rhapsody-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color var(--rhapsody-transition);
}

.rhapsody-modal-close:hover {
  color: var(--color-rhapsody-text);
}

.rhapsody-modal-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-rhapsody-surface), 0 0 0 4px var(--color-rhapsody-primary);
}

/* Native <dialog> element: centered, rounded, clickable backdrop */
.rhapsody-modal-dialog {
  border-radius: var(--rhapsody-radius-xl);
  overflow: hidden;
  width: 100%;
  max-width: 28rem;
  margin: auto;
  position: fixed;
  inset: 0;
  height: min-content;
}

.rhapsody-modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

/* Video player modal (larger, with custom controls) */
.rhapsody-video-player {
  max-width: 56rem;
  width: 90vw;
}

.rhapsody-video-player--large {
  max-width: 72rem;
  width: 92vw;
}

.rhapsody-video-player-video-wrapper {
  aspect-ratio: 16 / 9;
  position: relative;
}

.rhapsody-video-player-video {
  object-fit: contain;
}

.rhapsody-video-player-controls {
  border-top: 1px solid var(--color-rhapsody-border);
}

.rhapsody-video-player-btn {
  transition: opacity 0.15s;
  cursor: pointer;
}

.rhapsody-video-player-btn:hover {
  opacity: 0.8;
}

.rhapsody-video-player-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-rhapsody-primary);
}

.rhapsody-video-player-progress {
  transition: background 0.15s;
}

.rhapsody-video-player-progress:hover {
  background: var(--color-rhapsody-gray-400) !important;
}

.rhapsody-video-player-volume-input {
  accent-color: var(--color-rhapsody-primary);
  cursor: pointer;
}

.rhapsody-video-player-speed {
  cursor: pointer;
  font-family: inherit;
}

.rhapsody-video-player-hidden {
  display: none !important;
}

/* 6. Dark mode support */
[data-theme="dark"],
.dark {
  --color-rhapsody-primary: var(--color-rhapsody-teal-300);
  --color-rhapsody-primary-dark: var(--color-rhapsody-teal-200);
  --color-rhapsody-primary-light: var(--color-rhapsody-teal-400);
  --color-rhapsody-accent: var(--color-rhapsody-orange-400);
  --color-rhapsody-background: var(--color-rhapsody-gray-900);
  --color-rhapsody-surface: var(--color-rhapsody-gray-800);
  --color-rhapsody-text: var(--color-rhapsody-cream-50);
  --color-rhapsody-text-muted: var(--color-rhapsody-gray-400);
  --color-rhapsody-border: var(--color-rhapsody-gray-700);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-rhapsody-primary: var(--color-rhapsody-teal-300);
    --color-rhapsody-primary-dark: var(--color-rhapsody-teal-200);
    --color-rhapsody-accent: var(--color-rhapsody-orange-400);
    --color-rhapsody-background: var(--color-rhapsody-gray-900);
    --color-rhapsody-surface: var(--color-rhapsody-gray-800);
    --color-rhapsody-text: var(--color-rhapsody-cream-50);
    --color-rhapsody-text-muted: var(--color-rhapsody-gray-400);
    --color-rhapsody-border: var(--color-rhapsody-gray-700);
  }
}

.dark .rhapsody-card,
[data-theme="dark"] .rhapsody-card {
  background-color: var(--color-rhapsody-surface);
  border-color: var(--color-rhapsody-border);
  color: var(--color-rhapsody-text);
}

.dark .rhapsody-mini-player,
[data-theme="dark"] .rhapsody-mini-player {
  background-color: var(--color-rhapsody-surface);
  border-color: var(--color-rhapsody-border);
}

.dark .rhapsody-mini-player-artwork,
[data-theme="dark"] .rhapsody-mini-player-artwork {
  background-color: var(--color-rhapsody-border);
}

.dark .rhapsody-mini-player-speed,
[data-theme="dark"] .rhapsody-mini-player-speed {
  background-color: var(--color-rhapsody-surface);
  border-color: var(--color-rhapsody-border);
  color: var(--color-rhapsody-text);
}

.dark .rhapsody-modal-content,
[data-theme="dark"] .rhapsody-modal-content {
  background-color: var(--color-rhapsody-surface);
  border-color: var(--color-rhapsody-border);
  color: var(--color-rhapsody-text);
}

.dark .rhapsody-modal-header,
.dark .rhapsody-modal-footer,
[data-theme="dark"] .rhapsody-modal-header,
[data-theme="dark"] .rhapsody-modal-footer {
  border-color: var(--color-rhapsody-border);
}

.dark .rhapsody-table tbody tr,
[data-theme="dark"] .rhapsody-table tbody tr {
  background-color: var(--color-rhapsody-surface);
}

.dark .rhapsody-table tbody tr:hover,
[data-theme="dark"] .rhapsody-table tbody tr:hover {
  background-color: var(--color-rhapsody-gray-700);
}

/* Collapsible sidebar (used with sidebar Stimulus controller) */
.rhapsody-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 14rem;
  min-width: 14rem;
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  flex-direction: column;
  display: flex;
  z-index: 110;
  transition: width 0.2s ease, min-width 0.2s ease, transform 0.3s ease;
  overflow: hidden;
}
/* Keep sidebar footer above the fixed mini player */
.rhapsody-content-with-player .rhapsody-sidebar {
  padding-bottom: 5.5rem;
}
/* Content area: margin so it doesn't sit under the fixed sidebar */
.content-with-player {
  position: relative;
  margin-left: 0;
  min-width: 0;
  transition: margin-left 0.2s ease;
}
@media (min-width: 768px) {
  .content-with-player {
    margin-left: 14rem;
  }
  body:has(.rhapsody-sidebar.sidebar--collapsed) .content-with-player {
    margin-left: 3.5rem;
  }
}
/* Player: right of sidebar only; lower z-index so sidebar bottom stays on top */
body.rhapsody-content-with-player .rhapsody-mini-player {
  position: fixed !important;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  transition: left 0.2s ease;
}
@media (min-width: 768px) {
  body.rhapsody-content-with-player .rhapsody-mini-player {
    left: 14rem;
  }
  body.rhapsody-content-with-player:has(.rhapsody-sidebar.sidebar--collapsed) .rhapsody-mini-player {
    left: 3.5rem;
  }
}
/* Reserve space above the fixed player so the bottom of the page can scroll into view */
.content-with-player main {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  padding-bottom: 6rem;
  scroll-padding-bottom: 5rem;
}
@media (min-width: 768px) {
  .content-with-player main {
    padding-bottom: 14rem;
    scroll-padding-bottom: 6rem;
  }
}
/* No extra body padding when player is in content column */
body.rhapsody-content-with-player:has(.content-with-player) {
  padding-bottom: 0;
}
.rhapsody-sidebar.sidebar--collapsed {
  width: 3.5rem;
  min-width: 3.5rem;
}
.rhapsody-sidebar.sidebar--collapsed .rhapsody-sidebar__label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  padding: 0;
}
.rhapsody-sidebar .rhapsody-sidebar__label {
  transition: opacity 0.15s ease;
}

/* 7. Responsive layout */
@media (max-width: 767px) {
  /* Sidebar: overlay drawer on mobile */
  .rhapsody-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 16rem;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform var(--rhapsody-transition-smooth);
    z-index: 120;
    box-shadow: 4px 0 12px rgb(0 0 0 / 0.1);
  }
  .rhapsody-sidebar.sidebar--open {
    transform: translateX(0);
  }
  /* On mobile, always show full width when open (ignore collapsed) */
  .rhapsody-sidebar.sidebar--open.sidebar--collapsed {
    width: 16rem;
    min-width: 16rem;
  }
  .rhapsody-sidebar.sidebar--open .rhapsody-sidebar__label {
    opacity: 1;
    width: auto;
    overflow: visible;
    white-space: normal;
    padding: inherit;
  }
  /* Backdrop when sidebar overlay is open */
  .rhapsody-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgb(0 0 0 / 0.4);
    z-index: 115;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--rhapsody-transition-smooth);
  }
  .rhapsody-sidebar-backdrop.sidebar-backdrop--visible {
    opacity: 1;
    pointer-events: auto;
  }
  /* Modal: full width on small screens */
  .rhapsody-modal {
    padding: 0.5rem;
    align-items: flex-end;
  }
  .rhapsody-modal-content {
    max-width: 100%;
    margin-bottom: 0.5rem;
    border-radius: var(--rhapsody-radius-lg) var(--rhapsody-radius-lg) 0 0;
  }
  .rhapsody-modal-content.rhapsody-modal-sm,
  .rhapsody-modal-content.rhapsody-modal-lg,
  .rhapsody-modal-content.rhapsody-modal-xl {
    max-width: 100%;
  }
  /* Mini player: compact on mobile */
  .rhapsody-mini-player {
    padding: 0.375rem 0.75rem;
    gap: 0.75rem;
    min-height: 4rem;
  }
  .rhapsody-mini-player-artwork {
    width: 2.5rem;
    height: 2.5rem;
  }
  .rhapsody-mini-player-title {
    font-size: 0.8125rem;
  }
  .rhapsody-mini-player-time {
    font-size: 0.6875rem;
    min-width: 2.5rem;
  }
  .rhapsody-mini-player-volume {
    display: none;
  }
  .rhapsody-mini-player-speed {
    font-size: 0.6875rem;
    padding: 0.125rem 0.25rem;
  }
  .rhapsody-content-with-player {
    padding-bottom: 4.5rem;
  }
}

@media (min-width: 768px) {
  .rhapsody-sidebar-backdrop {
    display: none;
  }
}
