:root {
  color-scheme: dark;
  --bg: #070a12;
  --bg-2: #0a0e18;
  --panel: #0e1320;
  --panel-2: #131a2b;
  --panel-3: #172033;
  --row: #0e1421;
  --row-hover: #131c2e;
  --text: #f4f6ff;
  --muted: #9aa4bd;
  --faint: #6d7690;
  --line: rgba(150, 165, 200, 0.12);
  --line-strong: rgba(150, 165, 200, 0.2);
  --accent: #875cff;
  --accent-soft: rgba(135, 92, 255, 0.16);
  --accent-2: #39cde4;
  --green: #66d98a;
  --danger: #ff8993;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 20px 46px rgba(0, 0, 0, 0.42);
  --shadow-pop: 0 14px 34px rgba(0, 0, 0, 0.5);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  scroll-padding-top: 92px;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(1100px 480px at 72% -8%, rgba(135, 92, 255, 0.1), transparent 60%),
    radial-gradient(900px 420px at 8% 0%, rgba(57, 205, 228, 0.06), transparent 55%),
    linear-gradient(180deg, #070b15 0%, #06080f 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.icon {
  display: block;
  flex: 0 0 auto;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.06s ease;
}

button:hover {
  border-color: rgba(135, 92, 255, 0.55);
  background: var(--panel-3);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(57, 205, 228, 0.28);
  outline-offset: 1px;
}

button.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, #7a4ff2, #9a6bff);
  box-shadow: 0 12px 24px rgba(135, 92, 255, 0.28);
}

button.primary:hover {
  background: linear-gradient(135deg, #8358ff, #a679ff);
}

button.ghost {
  background: transparent;
}

button.danger {
  color: #ffadb4;
}

button.danger:hover {
  border-color: rgba(255, 130, 141, 0.5);
  background: rgba(255, 130, 141, 0.08);
}

/* ---------- app shell ---------- */

.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: 78px minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar"
    "sidebar workspace";
  min-height: 100vh;
}

/* ---------- topbar ---------- */

.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) max-content;
  gap: 18px;
  align-items: center;
  min-width: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 20, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand h1 {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.logoMark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: url("/icon-192.png") center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 18px rgba(135, 92, 255, 0.3);
}

.brand p {
  margin: 0;
  padding-left: 45px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.globalSearch {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
  height: 46px;
  margin: 0;
  padding: 0 8px 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(13, 18, 30, 0.9);
  transition: border-color 0.15s ease;
}

.globalSearch:focus-within {
  border-color: rgba(135, 92, 255, 0.55);
}

.searchIconBtn {
  min-height: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  color: var(--faint);
  background: transparent;
}

.searchIconBtn:hover {
  background: transparent;
  color: var(--muted);
}

.globalSearch input {
  min-width: 0;
  height: 40px;
  border: 0;
  color: var(--text);
  background: transparent;
  font-size: 14px;
}

.globalSearch input:focus-visible {
  outline: none;
}

.kbdHint,
.shortcutList kbd,
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(20, 27, 44, 0.9);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
}

.topActions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.iconBtn {
  width: 40px;
  min-height: 40px;
  padding: 0;
  color: var(--muted);
}

.iconBtn:hover {
  color: var(--text);
}

.topActions .primary {
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
}

.btnIcon {
  display: inline-flex;
}

.avatarBtn {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(145deg, #f6b352, #ef8f4b);
  border-color: transparent;
}

/* ---------- sidebar ---------- */

.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 78px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  height: calc(100vh - 78px);
  min-width: 0;
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10, 14, 24, 0.6), rgba(8, 10, 20, 0.4));
}

.navPanel {
  display: grid;
  gap: 3px;
}

.navPanel button,
.quickFilters button {
  justify-content: flex-start;
  min-height: 42px;
  padding: 0 13px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.navPanel button:hover,
.quickFilters button:hover {
  color: var(--text);
  background: var(--panel-2);
}

.navPanel button.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(135, 92, 255, 0.9), rgba(122, 79, 242, 0.75));
  box-shadow: 0 8px 18px rgba(135, 92, 255, 0.3);
}

.navPanel button.active .navIcon,
.quickFilters button.active {
  color: #fff;
}

.navIcon {
  display: inline-flex;
  color: inherit;
  opacity: 0.92;
}

.sidebarContent {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.panel {
  display: grid;
  gap: 3px;
}

.quickFilters > label {
  padding: 6px 8px 4px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.quickFilters button.active {
  color: var(--text);
  background: var(--accent-soft);
}

#saveStatus {
  margin: 8px 8px 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}

.clearBtn,
#clearBtn {
  justify-content: flex-start;
  padding: 0 13px;
  min-height: 38px;
  border: 0;
}

/* ---------- now playing ---------- */

.playerPanel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(23, 30, 51, 0.82), rgba(14, 19, 32, 0.82));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nowPlayingHead {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
}

.nowPlayingInfo {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.nowPlayingInfo strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

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

.nowPlayingSettingsBtn,
#nowPlayingSettingsBtn {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  color: var(--faint);
  background: transparent;
}

.seekRow,
.volumeRow {
  display: flex;
  align-items: center;
  gap: 9px;
}

.timeLabel {
  min-width: 30px;
  color: var(--faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.timeLabel:last-child {
  text-align: right;
}

input[type="range"] {
  flex: 1;
  width: 100%;
  height: 4px;
  margin: 0;
  padding: 0;
  min-height: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(150, 165, 200, 0.2);
  accent-color: var(--accent);
  cursor: pointer;
}

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

.transportBtn {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: var(--text);
  background: rgba(150, 165, 200, 0.1);
}

.transportBtn:hover {
  background: rgba(150, 165, 200, 0.18);
}

.transportBtn.primary {
  width: 46px;
  min-height: 46px;
  color: #fff;
  background: linear-gradient(135deg, #7a4ff2, #9a6bff);
}

.volumeRow {
  flex: 1;
  margin-left: 4px;
  color: var(--faint);
}

.volumeRow .navIcon {
  flex: 0 0 auto;
}

/* ---------- workspace ---------- */

.workspace {
  grid-area: workspace;
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto;
  align-content: start;
  min-width: 0;
  padding: 20px 22px 12px;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
}

.toolbar h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.backLink {
  min-height: 0;
  padding: 4px 10px 4px 6px;
  margin-right: 6px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 14px;
  vertical-align: middle;
}

/* ---------- filter bar ---------- */

.filterBar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
}

.filterBar[hidden] {
  display: none;
}

.filterGroup {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filterGroup[hidden] {
  display: none;
}

.pillSelect {
  appearance: none;
  min-height: 40px;
  width: auto;
  padding: 0 34px 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background-color: var(--panel-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e97ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.pillSelect:hover {
  border-color: rgba(135, 92, 255, 0.5);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
}

.segmented button {
  min-height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}

.segmented button.active {
  color: #fff;
  background: var(--accent);
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.checkline input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--accent);
}

#resetFiltersBtn {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 999px;
  color: var(--muted);
}

.viewToggle {
  display: inline-flex;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

.viewToggleBtn {
  width: 36px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--faint);
  background: transparent;
}

.viewToggleBtn.active {
  color: #fff;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- category cards ---------- */

.categoryCards {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 18px;
  scrollbar-width: thin;
}

.categoryCards[hidden],
.cloudBrowser[hidden],
.collectionsBrowser[hidden] {
  display: none;
}

.categoryCard {
  display: grid;
  place-items: center;
  gap: 3px;
  flex: 0 0 auto;
  width: 96px;
  min-height: 104px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel);
}

.categoryCard:hover {
  border-color: rgba(135, 92, 255, 0.5);
  background: var(--panel-2);
}

.categoryCard.active {
  border-color: rgba(135, 92, 255, 0.7);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(135, 92, 255, 0.4) inset;
}

.categoryCard .allCard {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
}

.categoryLabel {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.categoryCount {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
}

.moreCard {
  gap: 6px;
}

.categoryCardsLarge {
  flex-wrap: wrap;
}

.categoryCard.large {
  width: 132px;
  min-height: 128px;
  gap: 6px;
}

.categoryCard.empty {
  opacity: 0.55;
}

/* ---------- env thumb ---------- */

.envThumb {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.92);
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--env-color, #8992a8) 78%, #000), color-mix(in srgb, var(--env-color, #8992a8) 38%, #05070d));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.envThumb .icon {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.envThumb.sizeSm {
  width: 40px;
  height: 40px;
}

.envThumb.sizeMd {
  width: 46px;
  height: 46px;
}

.envThumb.sizeCard {
  width: 52px;
  height: 52px;
  border-radius: 11px;
}

.envThumb.sizeLg {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 11px 11px 0 0;
}

/* ---------- results table ---------- */

.resultsHeader {
  display: grid;
  grid-template-columns: 40px 46px minmax(140px, 1.2fr) minmax(96px, 0.9fr) minmax(160px, 1.1fr) 122px 68px 100px 72px;
  gap: 12px;
  padding: 0 14px 10px 14px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.resultsHeader[hidden] {
  display: none;
}

.results {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  padding-bottom: 8px;
}

.results[hidden],
.resultsGrid[hidden] {
  display: none;
}

.result {
  display: grid;
  grid-template-columns: 40px 46px minmax(140px, 1.2fr) minmax(96px, 0.9fr) minmax(160px, 1.1fr) 122px 68px 100px 72px;
  gap: 12px;
  align-items: center;
  min-width: 0;
  min-height: 74px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(14, 19, 32, 0.72);
  transition: background 0.14s ease, border-color 0.14s ease;
}

.result:hover {
  background: var(--row-hover);
}

.result.selected {
  border-color: rgba(135, 92, 255, 0.5);
  box-shadow: 0 0 0 1px rgba(135, 92, 255, 0.18);
}

.result.saved {
  border-color: rgba(135, 92, 255, 0.16);
}

.playBtn {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #fff;
  background: rgba(40, 49, 72, 0.9);
}

.playBtn:hover,
.playBtn.playing {
  border-color: transparent;
  background: linear-gradient(135deg, #7a4ff2, #9a6bff);
}

.titleBlock {
  min-width: 0;
}

.name {
  overflow: hidden;
  color: #fcfdff;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.assetLine {
  margin-top: 3px;
  overflow: hidden;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.assetLine code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  height: 30px;
}

.waveform span {
  display: block;
  flex: 1;
  min-height: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--wave-color, #a071ff), color-mix(in srgb, var(--wave-color, #39cde4) 45%, transparent));
  opacity: 0.85;
}

.metaCell {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.metaTop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.envSelectWrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 9px;
  border-radius: 999px;
  color: var(--env-color, #8992a8);
  background: color-mix(in srgb, var(--env-color, #8992a8) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--env-color, #8992a8) 34%, transparent);
  font-size: 11px;
  font-weight: 750;
}

.envSelect {
  appearance: none;
  min-height: 0;
  width: auto;
  max-width: 104px;
  padding: 0 2px;
  border: 0;
  color: inherit;
  background: transparent;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.envSelect option {
  color: var(--text);
  background: var(--panel-2);
}

.tagBadges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tagBadges span {
  max-width: 118px;
  padding: 2px 8px;
  overflow: hidden;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(150, 165, 200, 0.1);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
}

.envBadge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--env-color, #8992a8);
  background: color-mix(in srgb, var(--env-color, #8992a8) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--env-color, #8992a8) 34%, transparent);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.tagsInput {
  width: 100%;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(8, 12, 22, 0.6);
  font-size: 11px;
}

.tagsInput::placeholder {
  color: var(--faint);
}

.rating {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.star {
  width: 22px;
  min-height: 24px;
  padding: 0;
  border: 0;
  color: #39405a;
  background: transparent;
}

.star:hover {
  color: #b8a1ff;
  background: transparent;
}

.star.active {
  color: var(--accent);
}

.durationCell,
.addedCell {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.addedCell {
  color: var(--faint);
}

.rowActions {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  justify-content: flex-end;
}

.heartBtn,
.menuBtn {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--faint);
  background: transparent;
}

.heartBtn:hover,
.menuBtn:hover {
  color: var(--text);
  background: rgba(150, 165, 200, 0.1);
}

.heartBtn.active {
  color: var(--accent);
}

.rowMenu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 12;
  display: grid;
  gap: 2px;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel-2);
  box-shadow: var(--shadow-pop);
}

.rowMenu[hidden] {
  display: none;
}

.rowMenu button {
  justify-content: flex-start;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}

.rowMenu button:hover {
  color: var(--text);
  background: var(--panel-3);
}

.rowMenu button.danger:hover {
  background: rgba(255, 130, 141, 0.1);
}

/* ---------- grid view ---------- */

.resultsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  align-content: start;
  padding-bottom: 8px;
}

.card {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(14, 19, 32, 0.72);
  overflow: hidden;
  transition: border-color 0.14s ease, transform 0.1s ease;
}

.card:hover {
  border-color: rgba(135, 92, 255, 0.4);
  transform: translateY(-2px);
}

.card.selected {
  border-color: rgba(135, 92, 255, 0.6);
}

.cardThumb {
  position: relative;
}

.cardThumb .playBtn {
  position: absolute;
  left: 10px;
  bottom: 10px;
}

.cardHeart {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
}

.cardHeart:hover {
  background: rgba(0, 0, 0, 0.45);
}

.cardHeart.active {
  color: #fff;
}

.cardBody {
  display: grid;
  gap: 8px;
  padding: 12px 13px 13px;
}

.cardFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cardMeta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- browsers ---------- */

.cloudBrowser {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: start;
  padding: 4px 0 16px;
}

.tagChip {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel);
  font-weight: 650;
}

.tagChip:hover {
  border-color: rgba(135, 92, 255, 0.55);
  background: var(--panel-2);
}

.tagChip span {
  margin-left: 8px;
  color: var(--accent);
  font-size: 0.72em;
  font-weight: 800;
}

.collectionsBrowser {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  align-content: start;
  padding: 4px 0 16px;
}

.collectionCard {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
}

.collectionCard:hover {
  border-color: rgba(135, 92, 255, 0.5);
  background: var(--panel-2);
}

.collectionIcon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
}

.collectionInfo {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.collectionInfo strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.collectionInfo span {
  color: var(--faint);
  font-size: 12px;
}

.collectionDelete {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  color: var(--faint);
}

.collectionDelete:hover {
  color: var(--danger);
  background: rgba(255, 130, 141, 0.1);
}

.newCollectionCard {
  border-style: dashed;
  color: var(--muted);
}

/* ---------- pagination ---------- */

.paginationBar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 2px 4px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
}

.paginationBar[hidden] {
  display: none;
}

#paginationSummary {
  color: var(--muted);
  font-size: 13px;
}

.pageButtons {
  display: inline-flex;
  gap: 5px;
  justify-self: center;
}

.pageBtn {
  min-width: 36px;
  min-height: 36px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 650;
}

.pageBtn:hover:not(:disabled) {
  border-color: rgba(135, 92, 255, 0.5);
  color: var(--text);
}

.pageBtn.active {
  border-color: transparent;
  color: #fff;
  background: var(--accent);
}

.pageBtn:disabled {
  opacity: 0.4;
  cursor: default;
}

.perPage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.perPage .pillSelect {
  min-height: 34px;
  padding: 0 30px 0 12px;
}

/* ---------- state + empty ---------- */

.state {
  min-height: 20px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.state.error {
  color: var(--danger);
}

.emptyState {
  grid-column: 1 / -1;
  padding: 40px 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(14, 19, 32, 0.5);
  text-align: center;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: none;
  max-width: min(540px, calc(100vw - 36px));
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: rgba(18, 25, 41, 0.98);
  box-shadow: var(--shadow-pop);
  font-size: 13px;
}

.toast.visible {
  display: block;
}

.toast.error {
  border-color: rgba(255, 130, 141, 0.5);
  color: #ffb5bc;
  background: rgba(49, 21, 31, 0.98);
}

/* ---------- dialogs ---------- */

dialog {
  width: min(920px, calc(100vw - 28px));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

#addSoundDialog,
#newCollectionDialog,
#collectionPickerDialog,
#helpDialog {
  width: min(480px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(2, 4, 10, 0.68);
  backdrop-filter: blur(3px);
}

.dialogForm {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialogForm header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialogForm h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.dialogForm header button {
  padding: 0 12px;
}

.dialogForm footer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dialogForm label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.dialogForm input[type="text"],
.dialogForm select,
.dialogForm textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: rgba(8, 12, 22, 0.8);
}

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

.exportControls label {
  width: 190px;
}

#exportText {
  width: 100%;
  min-height: 420px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  resize: vertical;
  color: var(--text);
  background: rgba(8, 12, 22, 0.8);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.shortcutList {
  display: grid;
  gap: 8px;
}

.shortcutList > div {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.shortcutList span {
  margin-left: 4px;
}

.collectionPickerList {
  display: grid;
  gap: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.pickerRow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--panel-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.pickerRow span {
  flex: 1;
}

.pickerRow em {
  color: var(--faint);
  font-style: normal;
  font-size: 12px;
}

.pickerRow input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--accent);
}

.collectionPickerNew {
  display: flex;
  gap: 8px;
}

.collectionPickerNew input {
  flex: 1;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: rgba(8, 12, 22, 0.8);
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .topbar {
    grid-template-columns: 216px minmax(0, 1fr) max-content;
  }

  .brand p {
    display: none;
  }
}

@media (max-width: 1240px) {
  .resultsHeader,
  .result {
    grid-template-columns: 40px 46px minmax(140px, 1.4fr) minmax(160px, 1.2fr) 122px 68px 72px;
  }

  .waveform,
  .addedCell,
  .resultsHeader span:nth-child(4),
  .resultsHeader span:nth-child(8) {
    display: none;
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "sidebar"
      "workspace";
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 12px 14px;
  }

  .brand h1 {
    font-size: 0;
    gap: 0;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar .navPanel {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .navPanel button {
    white-space: nowrap;
  }

  .sidebarContent,
  .playerPanel {
    display: none;
  }

  .workspace {
    padding: 16px 14px 12px;
  }
}

@media (max-width: 720px) {
  .globalSearch {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .kbdHint {
    display: none;
  }

  .topActions .primary span {
    display: none;
  }

  .paginationBar {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 10px;
    text-align: center;
  }

  .perPage,
  .pageButtons {
    justify-self: center;
  }

  .viewToggle {
    margin-left: 0;
  }
}
