:root {
  --bg-deep: #000000;
  --bg-elevated: #0a0a0a;
  --bg-card: #111111;
  --bg-row: #111111;
  --bg-row-alt: #0a0a0a;
  --border-soft: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text-primary: #fff4f4;
  --text-secondary: #d4b0b0;
  --text-muted: #8a6363;
  --accent-red: #e5001a;
  --accent-red-dim: #9c0012;
  --accent-yellow: #ffd200;
  --accent-yellow-dim: #b89600;
  --accent-green: #41d68e;
  --gradient-pulse: linear-gradient(
    90deg,
    #1a0000 0%,
    #5a0010 40%,
    #e5001a 60%,
    #9c0012 80%,
    #1a0000 100%
  );
  --gradient-button: linear-gradient(135deg, #e5001a 0%, #ffd200 100%);
  --shadow-card: 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-button: 0 12px 24px rgba(229, 0, 26, 0.4);
  --radius-md: 14px;
  --radius-sm: 8px;
  --radius-lg: 22px;
  --player-bar-height: 92px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Inter", "SF Pro Display", "Segoe UI", system-ui, -apple-system,
    sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-deep);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "topbar"
    "layout"
    "player";
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----------------------- Top bar ----------------------- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: linear-gradient(
    180deg,
    rgba(6, 2, 2, 0.97) 0%,
    rgba(6, 2, 2, 0.78) 100%
  );
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 30;
}

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

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px;
  object-fit: contain;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.brand-title h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.brand-title p {
  margin: 2px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.mode-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  gap: 6px;
}

.mode-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.mode-button .mode-icon {
  font-size: 14px;
  line-height: 1;
}

.mode-button:hover {
  color: var(--text-primary);
}

.mode-button.is-active {
  background: #000000;
  color: #ffffff;
  box-shadow: var(--shadow-button);
}

/* ----------------------- Layout ----------------------- */
.layout {
  grid-area: layout;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding: 24px 28px calc(var(--player-bar-height) + 28px);
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 100px;
  align-self: flex-start;
  max-height: calc(100vh - 200px);
  overflow: auto;
  padding-right: 6px;
}

.sidebar-section {
  background: rgba(20, 8, 8, 0.65);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 10px;
}

.sidebar-header h2 {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0;
  color: var(--text-muted);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-list li button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.15s ease, color 0.15s ease, border 0.15s ease;
}

.nav-list li button:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-list li button.is-active {
  background: linear-gradient(135deg, rgba(229, 0, 26, 0.28), rgba(255, 210, 0, 0.12));
  color: var(--text-primary);
  border-color: rgba(229, 0, 26, 0.45);
}

.nav-list li .nav-count {
  font-size: 11px;
  color: var(--text-muted);
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* ----------------------- Content ----------------------- */
.content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.content-header h2 {
  margin: 4px 0 8px;
  font-size: 32px;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.content-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  border: 0;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-button {
  background: #000000;
  color: #fff;
  box-shadow: var(--shadow-button);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-soft);
}

.secondary-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.content-body {
  background: rgba(20, 8, 8, 0.55);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* ----------------------- Filter bar ----------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(20, 8, 8, 0.55);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.25);
  position: relative;
}

.search-field {
  flex: 1 1 280px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 6px 14px;
  min-width: 220px;
}

.search-field:focus-within {
  border-color: rgba(229, 0, 26, 0.5);
  background: rgba(255, 255, 255, 0.06);
}

.search-icon {
  color: var(--text-muted);
  font-size: 14px;
}

.search-field input[type="search"] {
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text-primary);
  width: 100%;
  font-size: 13px;
  padding: 4px 0;
}

.search-field input[type="search"]::placeholder {
  color: var(--text-muted);
}

.facet {
  position: relative;
}

.facet-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.facet-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
}

.facet-toggle.is-active {
  border-color: rgba(255, 210, 0, 0.55);
  background: rgba(255, 210, 0, 0.1);
  color: #ffd200;
}

.facet-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 210, 0, 0.18);
  color: #ffd200;
  font-size: 11px;
  font-weight: 700;
}

.facet-toggle:not(.is-active) .facet-count {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.facet-caret {
  color: var(--text-muted);
  font-size: 12px;
}

.facet-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  max-width: 90vw;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 40;
}

.facet-panel[hidden] {
  display: none;
}

.facet-filter {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}

.facet-filter:focus {
  border-color: rgba(255, 210, 0, 0.45);
}

.facet-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.facet-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
  font-size: 13px;
  color: var(--text-secondary);
}

.facet-option:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.facet-option.is-selected {
  background: rgba(255, 210, 0, 0.1);
  border-color: rgba(255, 210, 0, 0.45);
  color: #ffd200;
}

.facet-option .facet-option-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.facet-option .facet-checkbox {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.facet-option.is-selected .facet-checkbox {
  border-color: var(--accent-yellow);
  background: var(--accent-yellow);
  color: #0a0000;
}

.facet-option-count {
  font-size: 11px;
  color: var(--text-muted);
}

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

.facet-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
  border-top: 1px solid var(--border-soft);
  margin-top: 2px;
}

.ghost-button.is-danger {
  border-color: rgba(229, 0, 26, 0.5);
  color: #ff8080;
}

.ghost-button.is-danger:hover {
  background: rgba(229, 0, 26, 0.15);
}

.filter-summary {
  margin: 0;
  flex-basis: 100%;
  font-size: 12px;
  color: var(--text-muted);
}

.filter-summary:empty {
  display: none;
}

.filter-summary strong {
  color: var(--text-primary);
}

.empty-state {
  padding: 60px 30px;
  text-align: center;
  color: var(--text-muted);
}

/* ----------------------- Track table ----------------------- */
.track-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.track-table thead th {
  position: sticky;
  top: 0;
  background: rgba(15, 13, 30, 0.96);
  z-index: 1;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.track-table tbody tr {
  border-top: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.0);
  transition: background 0.15s ease;
}

.track-table tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

.track-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
}

.track-table tbody tr.is-playing {
  background: linear-gradient(
    90deg,
    rgba(229, 0, 26, 0.22),
    rgba(255, 210, 0, 0.1)
  );
}

.track-table td {
  padding: 14px 18px;
  vertical-align: top;
}

.col-index {
  width: 50px;
  color: var(--text-muted);
}

.col-actions {
  width: 130px;
  text-align: right;
}

.col-video {
  width: 90px;
}

.col-genres,
.col-instruments {
  max-width: 220px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  white-space: nowrap;
}

.chip.is-genre {
  border-color: rgba(229, 0, 26, 0.45);
  color: #ff8080;
  background: rgba(229, 0, 26, 0.1);
}

.chip.is-instrument {
  border-color: rgba(255, 210, 0, 0.4);
  color: #ffd200;
  background: rgba(255, 210, 0, 0.08);
}

.chip.is-filterable {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease,
    border-color 0.12s ease;
}

.chip.is-filterable:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.chip.is-genre.is-filterable:hover {
  background: rgba(229, 0, 26, 0.2);
  border-color: rgba(229, 0, 26, 0.65);
}

.chip.is-instrument.is-filterable:hover {
  background: rgba(255, 210, 0, 0.16);
  border-color: rgba(255, 210, 0, 0.65);
}

.track-title {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.track-title small {
  font-weight: 400;
  color: var(--text-muted);
}

.track-summary {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.45;
  max-width: 60ch;
}

/* ----------------------- Description row ----------------------- */
.description-row td.col-description {
  padding: 0 18px 14px 18px;
  border-top: none;
  background: transparent;
}

.description-row.is-playing td.col-description {
  background: linear-gradient(
    90deg,
    rgba(229, 0, 26, 0.1),
    rgba(255, 210, 0, 0.05)
  );
}

.track-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
  max-width: 90ch;
  padding: 10px 14px;
  border-left: 2px solid rgba(229, 0, 26, 0.35);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 6px 6px 0;
}

.desc-rest {
  /* always visible on desktop */
}

.desc-chips {
  display: none; /* desktop: chips already in their own columns */
}

.desc-toggle {
  display: none; /* hidden on desktop */
}

.track-actions {
  display: inline-flex;
  gap: 6px;
}

.icon-button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border 0.15s ease;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.icon-button.is-primary {
  background: #000000;
  color: #fff;
  border: 0;
}

.badge-video {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 210, 0, 0.12);
  color: #ffd200;
  border: 1px solid rgba(255, 210, 0, 0.35);
}

.badge-audio {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
}

/* ----------------------- Video stage ----------------------- */
.video-stage {
  position: fixed;
  bottom: calc(var(--player-bar-height) + 20px);
  right: 30px;
  width: min(420px, 45vw);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  z-index: 25;
  box-shadow: 0 32px 60px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.video-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

/* ----------------------- Player bar ----------------------- */
.player-bar {
  grid-area: player;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1.1fr 1.5fr 2fr 0.8fr;
  gap: 18px;
  align-items: center;
  padding: 14px 28px;
  background: linear-gradient(
    180deg,
    rgba(10, 3, 3, 0.88) 0%,
    rgba(5, 2, 2, 0.99) 60%
  );
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 20;
}

.player-meta {
  min-width: 0;
}

.now-playing-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing-folder {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.control-button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.control-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.control-button.is-large {
  width: 48px;
  height: 48px;
  background: #000000;
  color: #fff;
  box-shadow: var(--shadow-button);
}

.control-button.is-active {
  color: var(--accent-yellow);
  background: rgba(255, 210, 0, 0.14);
}

.player-progress {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
}

input[type="range"] {
  -webkit-appearance: none;
  background: transparent;
  width: 100%;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--accent-red) var(--progress, 0%),
    rgba(255, 255, 255, 0.12) var(--progress, 0%)
  );
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

input[type="range"]::-moz-range-progress {
  background: linear-gradient(90deg, var(--accent-red), var(--accent-yellow));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-yellow);
  margin-top: -5px;
  cursor: pointer;
  border: 2px solid var(--accent-red);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-yellow);
  border: 2px solid var(--accent-red);
  cursor: pointer;
}

.player-volume {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.player-volume input[type="range"] {
  width: 110px;
}

/* ----------------------- Dialogs ----------------------- */
.dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0;
  color: var(--text-primary);
  max-width: 400px;
  box-shadow: var(--shadow-card);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.dialog-form {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog-form header h3 {
  margin: 0;
  font-size: 18px;
}

.dialog-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.dialog-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.dialog-field input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 14px;
}

.dialog-track-preview {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.dialog-list li button {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
}

.dialog-list li button:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ===================== Sidebar toggle button ===================== */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
  order: -1;
}

.sidebar-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--text-secondary);
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.sidebar-toggle:hover span {
  background: var(--text-primary);
}

body.sidebar-open .sidebar-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.sidebar-open .sidebar-toggle span:nth-child(2) {
  opacity: 0;
}

body.sidebar-open .sidebar-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ===================== Sidebar overlay ===================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 49;
}

.sidebar-overlay:not([hidden]) {
  display: block;
}

/* ===================== Tablet — 1100px ===================== */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-section {
    flex: 1 1 240px;
  }
}

/* ===================== Mobile — 768px ===================== */
@media (max-width: 768px) {
  :root {
    --player-bar-height: 148px;
  }

  /* --- Topbar --- */
  .topbar {
    padding: 12px 14px;
    gap: 10px;
  }

  .sidebar-toggle {
    display: flex;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .brand {
    gap: 9px;
  }

  .brand-title h1 {
    font-size: 16px;
  }

  .brand-title p {
    font-size: 11px;
  }

  .mode-button span:not(.mode-icon) {
    display: none;
  }

  .mode-button {
    padding: 8px 10px;
  }

  /* --- Sidebar becomes a fixed off-canvas drawer --- */
  .layout {
    grid-template-columns: 1fr;
    padding: 14px 14px calc(var(--player-bar-height) + 20px);
    gap: 14px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80vw;
    max-width: 320px;
    z-index: 50;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-strong);
    overflow-y: auto;
    padding: 64px 14px 20px;
    flex-direction: column;
    flex-wrap: nowrap;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: none;
    gap: 14px;
  }

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

  .sidebar-section {
    flex: none;
  }

  /* --- Content header --- */
  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .content-header h2 {
    font-size: 22px;
  }

  .content-actions {
    width: 100%;
  }

  .content-actions button {
    flex: 1 1 auto;
    font-size: 12px;
    padding: 8px 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* --- Filter bar --- */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .search-field {
    flex: none;
    min-width: 0;
  }

  .facet-panel {
    width: 100%;
    left: 0;
  }

  /* --- Track table: hide secondary columns --- */
  .col-index,
  .col-genres,
  .col-instruments,
  .col-video {
    display: none;
  }

  .track-table thead th.col-title {
    padding-left: 14px;
  }

  .track-table td.col-title {
    padding: 12px 14px;
  }

  .track-table td.col-actions {
    padding: 12px 10px;
    width: 80px;
  }

  .track-summary {
    max-width: none;
  }

  /* Description row — mobile: first sentence + expand */
  .description-row td.col-description {
    padding: 0 14px 12px 14px;
    display: table-cell; /* always visible — not hidden like other cols */
  }

  .desc-rest {
    display: none;
  }

  .description-row.is-expanded .desc-rest {
    display: inline;
  }

  .desc-chips {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
  }

  .desc-chips-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .description-row.is-expanded .desc-chips {
    display: flex;
  }

  .desc-toggle {
    display: inline-flex;
    align-items: center;
    margin-top: 6px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid rgba(229, 0, 26, 0.4);
    background: rgba(229, 0, 26, 0.08);
    color: #ff8080;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
  }

  .desc-toggle:hover {
    background: rgba(229, 0, 26, 0.16);
    border-color: rgba(229, 0, 26, 0.65);
  }

  .description-row.is-expanded .desc-toggle {
    border-color: rgba(255, 210, 0, 0.4);
    background: rgba(255, 210, 0, 0.08);
    color: #ffd200;
  }

  .track-desc {
    font-size: 12.5px;
    padding: 8px 10px;
  }

  /* --- Player bar: 3-row compact stack --- */
  .player-bar {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "meta"
      "controls"
      "progress";
    gap: 6px;
    padding: 10px 14px;
    align-items: center;
  }

  .player-meta {
    grid-area: meta;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .now-playing-title {
    font-size: 13px;
  }

  .player-controls {
    grid-area: controls;
    justify-content: center;
    gap: 4px;
  }

  .player-volume {
    display: none;
  }

  .player-progress {
    grid-area: progress;
    gap: 8px;
  }

  /* --- Video stage: inline on mobile --- */
  .video-stage {
    position: static;
    width: 100%;
    margin: 0 0 12px;
    aspect-ratio: 16 / 9;
  }

  /* --- Dialogs: full-width on mobile --- */
  .dialog {
    max-width: calc(100vw - 32px);
    margin: auto 16px;
  }
}

/* ===================== Light theme ===================== */
[data-theme="light"] {
  --bg-deep: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-row: #ffffff;
  --bg-row-alt: #f6f8fb;
  --border-soft: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.18);
  --text-primary: #0f141b;
  --text-secondary: #364152;
  --text-muted: #7a8699;
  --shadow-card: 0 14px 36px rgba(9, 15, 28, 0.12);
  --shadow-button: 0 10px 20px rgba(12, 18, 29, 0.18);
}

[data-theme="light"] body {
  background-color: var(--bg-deep);
  background-image: linear-gradient(180deg, #fafbfc 0%, #f1f3f6 100%);
}

[data-theme="light"] .topbar {
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.94) 100%);
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .player-bar {
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(247,249,252,0.99) 70%);
  border-top-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .sidebar-section,
[data-theme="light"] .content-body,
[data-theme="light"] .filter-bar,
[data-theme="light"] .dialog,
[data-theme="light"] .facet-panel,
[data-theme="light"] .floating-panel,
[data-theme="light"] .queue-panel {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 8px 24px rgba(9, 15, 28, 0.08);
}

[data-theme="light"] .sidebar-header,
[data-theme="light"] .queue-header,
[data-theme="light"] .facet-footer {
  border-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .search-field,
[data-theme="light"] .mode-toggle,
[data-theme="light"] .facet-toggle,
[data-theme="light"] .sort-select,
[data-theme="light"] .secondary-button,
[data-theme="light"] .ghost-button,
[data-theme="light"] .icon-button,
[data-theme="light"] .control-button,
[data-theme="light"] .sleep-preset,
[data-theme="light"] .dialog-field input,
[data-theme="light"] .facet-filter {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--text-secondary);
}

[data-theme="light"] .mode-button:hover,
[data-theme="light"] .facet-toggle:hover,
[data-theme="light"] .secondary-button:hover:not(:disabled),
[data-theme="light"] .ghost-button:hover,
[data-theme="light"] .icon-button:hover,
[data-theme="light"] .control-button:hover,
[data-theme="light"] .sleep-preset:hover {
  background: #eef2f8;
  color: var(--text-primary);
}

[data-theme="light"] .primary-button,
[data-theme="light"] .control-button.is-large,
[data-theme="light"] .mode-button.is-active,
[data-theme="light"] .icon-button.is-primary {
  background: #0f172a;
  color: #ffffff;
}

[data-theme="light"] .nav-list li button {
  color: var(--text-secondary);
}

[data-theme="light"] .nav-list li button:hover {
  background: #f0f4fa;
  color: var(--text-primary);
}

[data-theme="light"] .nav-list li button.is-active {
  background: #e8eef7;
  border-color: rgba(37, 99, 235, 0.35);
  color: #0f172a;
}

[data-theme="light"] .track-table thead th {
  background: #f8fafc;
  border-bottom-color: rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .track-table tbody tr.is-playing {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.11), rgba(56, 189, 248, 0.06));
}

[data-theme="light"] .track-table tbody tr {
  background: #ffffff;
  border-top-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .track-table tbody tr:nth-child(odd) {
  background: #f9fbfe;
}

[data-theme="light"] .track-table tbody tr:hover {
  background: #eef3fa;
}

[data-theme="light"] .track-desc {
  background: #f8fafc;
  border-left-color: rgba(37, 99, 235, 0.45);
  color: var(--text-secondary);
}

[data-theme="light"] .chip {
  background: #f1f5f9;
  border-color: rgba(15, 23, 42, 0.12);
  color: #334155;
}

[data-theme="light"] .chip.is-genre {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.35);
  color: #b91c1c;
}

[data-theme="light"] .chip.is-instrument {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #92400e;
}

[data-theme="light"] .badge-audio {
  background: #edf2f7;
  color: #475569;
  border-color: rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .badge-video {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.35);
}

[data-theme="light"] .queue-item:hover {
  background: #eef2f7;
}

[data-theme="light"] .queue-item.is-current {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.15), rgba(56, 189, 248, 0.08));
}

[data-theme="light"] .stat-card,
[data-theme="light"] .stats-top-list li,
[data-theme="light"] .dialog-track-preview {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.1);
}

/* ===================== Topbar extra icons ===================== */
.topbar-icon {
  font-size: 16px;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-soft);
}

[data-theme="light"] .topbar-icon {
  background: rgba(0,0,0,0.04);
}

/* ===================== Sidebar header actions ===================== */
.sidebar-header-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ===================== Sort control ===================== */
.sort-control {
  display: inline-flex;
  align-items: center;
}

.sort-select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  color: var(--text-primary);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.sort-select:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--border-strong);
}

.sort-select:focus {
  border-color: rgba(229,0,26,0.5);
}

[data-theme="light"] .sort-select {
  background: rgba(0,0,0,0.04);
}

/* ===================== Duration column ===================== */
.col-duration {
  width: 60px;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* ===================== Star / Favorite button ===================== */
.icon-button.is-star {
  font-size: 15px;
  color: var(--text-muted);
  transition: color 0.15s ease, background 0.15s ease;
}

.icon-button.is-star.is-active {
  color: #ffd200;
  background: rgba(255,210,0,0.12);
  border-color: rgba(255,210,0,0.45);
}

.icon-button.is-star:hover {
  color: #ffd200;
}

/* ===================== Queue panel ===================== */
.queue-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 300px;
  max-width: 90vw;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-strong);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -12px 0 40px rgba(0,0,0,0.4);
}

.queue-panel.is-open {
  transform: translateX(0);
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.queue-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.queue-count {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 12px;
}

.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.queue-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 32px 16px;
  margin: 0;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  border-radius: 8px;
  margin: 0 6px;
  transition: background 0.12s ease;
  user-select: none;
}

.queue-item:hover {
  background: rgba(255,255,255,0.05);
}

.queue-item.is-current {
  background: linear-gradient(90deg, rgba(229,0,26,0.2), rgba(255,210,0,0.08));
}

.queue-item.drag-over {
  border-top: 2px solid var(--accent-red);
}

.queue-item.is-dragging {
  opacity: 0.45;
}

.queue-num {
  font-size: 11px;
  color: var(--text-muted);
  width: 18px;
  flex-shrink: 0;
  text-align: right;
}

.queue-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.queue-track-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-track-folder {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-remove {
  width: 24px;
  height: 24px;
  font-size: 11px;
  opacity: 0.5;
  flex-shrink: 0;
}

.queue-item:hover .queue-remove {
  opacity: 1;
}

/* ===================== Floating panels (EQ, Sleep) ===================== */
.floating-panel {
  position: fixed;
  bottom: calc(var(--player-bar-height) + 10px);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
}

.floating-panel[hidden] {
  display: none;
}

.panel-heading {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ===================== Equalizer panel ===================== */
.eq-panel {
  right: 220px; /* above player-extra zone */
  min-width: 300px;
}

.eq-presets {
  display: flex;
  gap: 8px;
  align-items: center;
}

.eq-presets .sort-select {
  min-width: 140px;
}

.eq-curve {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.03);
  cursor: crosshair;
}

.eq-band-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.eq-row {
  display: grid;
  grid-template-columns: 46px 1fr 50px;
  align-items: center;
  gap: 10px;
}

.eq-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.eq-slider {
  width: 100%;
}

.eq-val {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

/* ===================== Sleep timer panel ===================== */
.sleep-panel {
  right: 140px; /* above sleep button zone */
}

.playback-panel {
  right: 170px;
  min-width: 280px;
}

.playback-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.playback-toggle input[type="checkbox"] {
  accent-color: var(--accent-red);
}

.sleep-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sleep-preset {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  color: var(--text-secondary);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sleep-preset:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.sleep-preset.is-active {
  background: rgba(229,0,26,0.15);
  border-color: rgba(229,0,26,0.55);
  color: #ff8080;
}

.sleep-status {
  margin: 0;
  font-size: 12px;
  color: var(--accent-yellow);
  font-weight: 600;
  min-height: 1em;
}

/* ===================== Player bar: new columns ===================== */
.player-bar {
  grid-template-columns: 1.1fr 1.5fr 2fr auto 0.8fr;
}

.player-extra {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.player-extra .control-button {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ===================== Seek wrap + waveform canvas ===================== */
.seek-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.waveform-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.3;
  pointer-events: none;
  border-radius: 4px;
}

.seek-wrap input[type="range"] {
  position: relative;
  z-index: 1;
  width: 100%;
}

/* Fix player-progress to use seek-wrap */
.player-progress {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ===================== Stats dialog ===================== */
.dialog-wide {
  max-width: 540px;
}

.stats-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stats-top-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.stats-top-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  font-size: 13px;
}

.stats-top-list .plays-badge {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.stats-section-title {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

/* ===================== Mobile adjustments ===================== */
@media (max-width: 768px) {
  .col-duration {
    display: none;
  }

  .player-bar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "meta"
      "controls"
      "progress"
      "extra";
    grid-template-rows: auto auto auto auto;
  }

  .player-extra {
    grid-area: extra;
    justify-content: center;
    padding-bottom: 2px;
  }

  :root {
    --player-bar-height: 168px;
  }

  .eq-panel,
  .sleep-panel {
    right: 8px;
    left: 8px;
    min-width: 0;
    width: auto;
  }

  .queue-panel {
    width: 85vw;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
