:root {
  /* Glassmorphic opacities mapping for Dark mode (Default) */
  --bg-base: var(--tg-theme-bg-color, #0a0813);
  --tab-bg: rgba(10, 8, 19, 0.4);
  --blob-opacity: 0.4;
  --glass-015: rgba(255, 255, 255, 0.015);
  --glass-02: rgba(255, 255, 255, 0.02);
  --glass-03: rgba(255, 255, 255, 0.03);
  --glass-04: rgba(255, 255, 255, 0.04);
  --glass-05: rgba(255, 255, 255, 0.05);
  --glass-06: rgba(255, 255, 255, 0.06);
  --glass-08: rgba(255, 255, 255, 0.08);
  --glass-10: rgba(255, 255, 255, 0.1);
  --glass-15: rgba(255, 255, 255, 0.15);
  --glass-30: rgba(255, 255, 255, 0.3);

  --dark-015: rgba(0, 0, 0, 0.15);
  --dark-02: rgba(0, 0, 0, 0.2);
  --dark-025: rgba(0, 0, 0, 0.25);
  --dark-035: rgba(0, 0, 0, 0.35);

  /* Adaptable colors based on Telegram WebApp variables */
  --tg-bg: var(--tg-theme-bg-color, #0b0813);
  --tg-sec-bg: var(--tg-theme-secondary-bg-color, #110c20);
  --tg-text: var(--tg-theme-text-color, #f3f0fc);
  --tg-hint: var(--tg-theme-hint-color, #8e87b7);
  --tg-btn: var(--tg-theme-button-color, #7209b7);
  --tg-btn-text: var(--tg-theme-button-text-color, #ffffff);

  --accent: var(--tg-theme-button-color, #7209b7);
  --accent-light: var(--tg-theme-link-color, #f72585);
  --accent-glow: color-mix(in srgb, var(--accent) 45%, transparent);
  --accent-light-glow: color-mix(in srgb, var(--accent-light) 30%, transparent);

  --success: var(--tg-theme-link-color, #4cc9f0);
  --success-glow: color-mix(in srgb, var(--success) 20%, transparent);
  --error: var(--tg-theme-destructive-text-color, #ff006e);
  --error-glow: color-mix(in srgb, var(--error) 25%, transparent);
  --warning: var(--tg-theme-hint-color, #ffbe0b);
  --warning-glow: color-mix(in srgb, var(--warning) 20%, transparent);
  --youtube: #ff6868;
  --soundcloud: #ffad42;

  --font-outfit:
    "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-inter:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="light"] {
  --bg-base: #ffffff;
  --tab-bg: rgba(255, 255, 255, 0.6);
  --blob-opacity: 0.15;

  --glass-015: rgba(0, 0, 0, 0.02);
  --glass-02: rgba(0, 0, 0, 0.03);
  --glass-03: rgba(0, 0, 0, 0.04);
  --glass-04: rgba(0, 0, 0, 0.05);
  --glass-05: rgba(0, 0, 0, 0.06);
  --glass-06: rgba(0, 0, 0, 0.07);
  --glass-08: rgba(0, 0, 0, 0.08);
  --glass-10: rgba(0, 0, 0, 0.1);
  --glass-15: rgba(0, 0, 0, 0.15);
  --glass-30: rgba(0, 0, 0, 0.3);

  --dark-015: rgba(255, 255, 255, 0.5);
  --dark-02: rgba(255, 255, 255, 0.6);
  --dark-025: rgba(255, 255, 255, 0.7);
  --dark-035: rgba(255, 255, 255, 0.8);

  --youtube: #b42318;
  --soundcloud: #934b00;
}

/*
 * Telegram defines --tg-theme-* variables even when its SDK is opened in
 * a regular browser. Keep browser colors explicit so those injected dark
 * values cannot become light text on the light browser background.
 */
[data-host="browser"][data-theme="light"] {
  color-scheme: light;
  --bg-base: #f8f7fb;
  --tab-bg: rgba(248, 247, 251, 0.92);
  --tg-bg: #f8f7fb;
  --tg-sec-bg: #ffffff;
  --tg-text: #211a2e;
  --tg-hint: #625a70;
  --tg-btn: #6e3aca;
  --tg-btn-text: #ffffff;
  --accent: #6e3aca;
  --accent-light: #b11663;
  --success: #087c72;
  --error: #c21d4f;
  --warning: #8a5d00;
}

[data-host="browser"][data-theme="dark"] {
  color-scheme: dark;
  --bg-base: #0a0813;
  --tab-bg: rgba(10, 8, 19, 0.82);
  --tg-bg: #0b0813;
  --tg-sec-bg: #110c20;
  --tg-text: #f3f0fc;
  --tg-hint: #a9a1c5;
  --tg-btn: #7209b7;
  --tg-btn-text: #ffffff;
  --accent: #7209b7;
  --accent-light: #f72585;
  --success: #4cc9f0;
  --error: #ff5c9c;
  --warning: #ffd166;
}

@keyframes dotPulse {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent-light) 70%, transparent);
  outline-offset: 2px;
}

body {
  background-color: var(--bg-base);
  color: var(--tg-text);
  font-family: var(--font-inter);
  height: 100vh;
  height: var(--tg-vh, 100vh);
  overflow: hidden;
  padding: 0;
  margin: 0;
  letter-spacing: -0.01em;
  display: flex;
  flex-direction: column;
}

#main-content {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.tab-pane {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 90px 16px;
}

.tab-pane.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  animation: fadeIn 0.4s ease forwards;
}

/* Top Gradient Mask */
.top-gradient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: linear-gradient(to bottom, var(--bg-base) 10%, transparent 100%);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: opacity;
}

/* Static Blob Background */
.blob-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
  background: var(--bg-base);
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--blob-opacity);
}
.blob1 {
  width: 300px;
  height: 300px;
  background: var(--accent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Glassmorphic Container (Removed visually by user request) */
.glass-card {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 20px;
  box-shadow: none;
}

.glass-card:hover {
  transform: none;
  box-shadow: none;
}

/* Brand & Typography */
h1.brand {
  font-family: var(--font-outfit);
  font-weight: 800;
  font-size: 26px;
  text-align: center;
  margin-top: 10px;
  margin-bottom: 5px;
  color: var(--tg-text, #ffffff);
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

p.subtitle {
  font-size: 13px;
  color: var(--tg-hint);
  text-align: center;
  margin-bottom: 24px;
  font-weight: 400;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  margin-bottom: 14px;
  padding: 0 4px;
}

.section-title {
  font-family: var(--font-outfit);
  font-weight: 700;
  font-size: 18px;
  color: var(--tg-text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title svg {
  color: var(--accent-light);
}

/* Inputs and Forms */
.input-group {
  position: relative;
  margin-bottom: 10px;
  width: 100%;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tg-hint);
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: color 0.2s ease;
}

.premium-input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  font-size: 16px;
  background: var(--dark-025);
  border: 1.5px solid var(--glass-08);
  border-radius: 12px;
  color: var(--tg-text);
  outline: none;
  transition: all 0.3s ease;
  font-family: var(--font-inter);
}

input.premium-input::placeholder {
  color: var(--tg-hint);
  opacity: 0.82;
}

.premium-input:focus {
  background: var(--dark-035);
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

input.premium-input:focus + .input-icon {
  color: var(--accent-light);
}

.list-search-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 15px;
}
.list-search-row .input-group {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.library-filter-menu {
  position: relative;
  flex: 0 0 auto;
}
.library-filter-menu > summary {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  position: relative;
  border: 1.5px solid var(--glass-08);
  border-radius: 12px;
  color: var(--tg-hint);
  background: var(--dark-025);
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.library-filter-menu > summary::-webkit-details-marker {
  display: none;
}
.library-filter-menu > summary.has-active-filters,
.library-filter-menu[open] > summary {
  border-color: var(--accent);
  color: var(--accent-light);
  background: color-mix(in srgb, var(--accent) 9%, var(--dark-025));
}
.library-filter-count {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  padding: 0 3px;
  border-radius: 999px;
  color: white;
  background: var(--accent);
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}
.library-filter-popover {
  position: absolute;
  top: 54px;
  right: 0;
  z-index: 80;
  width: min(280px, calc(100vw - 40px));
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--glass-10);
  border-radius: 14px;
  background: color-mix(in srgb, var(--tg-sec-bg) 97%, transparent);
  box-shadow: 0 14px 38px var(--dark-03);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.library-filter-popover label {
  display: grid;
  gap: 5px;
  color: var(--tg-hint);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.library-filter-popover .premium-input {
  padding: 9px 30px 9px 10px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}

/* Buttons & Actions */
button.premium-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--tg-btn, var(--accent));
  color: var(--tg-btn-text, #ffffff);
  font-family: var(--font-outfit);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px var(--dark-02);
  transition: all 0.2s ease;
}

button.premium-btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

button.premium-btn:disabled {
  background: var(--glass-08);
  color: var(--tg-hint);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

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

.refresh-btn:active {
  background: var(--glass-05);
  color: var(--tg-text);
  transform: scale(0.9);
}

.refresh-btn.rotating svg {
  animation: spin 1s linear infinite;
}

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

.browser-account-menu {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 45;
}

[data-host="telegram"] .browser-account-menu {
  display: none;
}
.browser-account-menu > summary {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: color-mix(in srgb, var(--tg-hint) 65%, transparent);
  background: transparent;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.browser-account-menu > summary::-webkit-details-marker {
  display: none;
}
.browser-account-menu > summary:active,
.browser-account-menu[open] > summary {
  border-color: var(--glass-10);
  color: var(--tg-text);
  background: color-mix(in srgb, var(--tg-sec-bg) 90%, transparent);
}
.browser-account-popover {
  position: absolute;
  top: 40px;
  right: 0;
  width: max-content;
  min-width: 132px;
  padding: 6px;
  border: 1px solid var(--glass-10);
  border-radius: 12px;
  background: color-mix(in srgb, var(--tg-sec-bg) 96%, transparent);
  box-shadow: 0 12px 32px var(--dark-025);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.browser-account-sign-out {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  color: var(--tg-hint);
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.browser-account-sign-out:active {
  color: var(--tg-text);
  background: var(--glass-05);
}
@media (hover: hover) {
  .browser-account-menu > summary:hover,
  .browser-account-sign-out:hover {
    color: var(--tg-text);
    background: var(--glass-05);
  }
}

/* --- File Picker Styles --- */
.drop-zone-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--tg-hint);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.drop-zone-divider::before,
.drop-zone-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--glass-08);
}

/* Inline Editing CSS */
.editing-mode .recent-item,
.editing-mode .track-item {
  opacity: 0.42;
  transition: opacity 0.2s ease;
}
@media (hover: hover) {
  .editing-mode .recent-item:not(.active-edit):hover,
  .editing-mode .track-item:not(.active-edit):hover {
    opacity: 0.75;
    background: var(--glass-03);
    border-color: var(--glass-08);
  }
}
.editing-mode .recent-item.active-edit,
.editing-mode .track-item.active-edit {
  opacity: 1;
  transform: translateZ(0);
  box-shadow: 0 8px 24px var(--dark-03);
  border-color: var(--accent-light);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0 !important;
  border-bottom: none;
  scroll-margin-top: 70px;
}

.edit-panel-anim {
  overflow: hidden;
  background: var(--dark-015);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  border: 1px solid var(--glass-10);
  border-top: none;
  box-shadow: inset 0 4px 15px rgba(0, 0, 0, 0.15);
  transform: translateZ(0);
  transform-origin: top;
}

.edit-panel-closed {
  display: none;
}

.edit-panel-open {
  display: block;
  opacity: 1;
  margin-top: 0;
  margin-bottom: 15px;
  padding: 12px;
  border: 1px solid var(--accent-light);
  border-top: none;
}

.drop-zone {
  position: relative;
  border: 2px dashed var(--glass-15);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  background: var(--dark-015);
  transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  overflow: hidden;
}
.drop-zone::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 0%,
    color-mix(in srgb, var(--accent) 7%, transparent) 0%,
    transparent 65%
  );
  pointer-events: none;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: color-mix(in srgb, var(--accent) 85%, transparent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 18%, transparent);
}
.drop-zone.drag-over {
  animation: dropPulse 0.8s ease infinite alternate;
}
@keyframes dropPulse {
  from {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 30%, transparent);
  }
  to {
    box-shadow: 0 0 0 6px transparent;
  }
}
.drop-zone-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 10px;
  color: color-mix(in srgb, var(--accent) 75%, transparent);
  transition: transform 0.25s ease;
}
.drop-zone:hover .drop-zone-icon,
.drop-zone.drag-over .drop-zone-icon {
  transform: translateY(-3px) scale(1.1);
  color: var(--accent-light);
}
.drop-zone-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--tg-text);
  margin-bottom: 4px;
}
.drop-zone-subtitle {
  font-size: 11.5px;
  color: var(--tg-hint);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.drop-zone-progress {
  margin-top: 10px;
  height: 3px;
  border-radius: 3px;
  background: var(--glass-06);
  overflow: hidden;
  display: none;
}
.drop-zone-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c4dff, #b47aff);
  border-radius: 3px;
  transition: width 0.3s ease;
  animation: progressPulse 1.5s ease infinite;
}
@keyframes progressPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

/* Status & Banner Alerts */
.status-alert {
  display: none;
  padding: 14px 16px;
  border-radius: 12px;
  margin-top: 15px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.5;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

.status-alert.info {
  display: flex;
  background: rgba(255, 190, 11, 0.1);
  border: 1px solid rgba(255, 190, 11, 0.2);
  color: var(--warning);
}

.status-alert.success {
  display: flex;
  background: rgba(76, 201, 240, 0.1);
  border: 1px solid rgba(76, 201, 240, 0.2);
  color: var(--success);
}

.status-alert.error {
  display: flex;
  background: rgba(255, 0, 110, 0.08);
  border: 1px solid rgba(255, 0, 110, 0.18);
  color: var(--error);
}

.swap-match-copy {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.swap-match-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swap-inline-action {
  flex: 0 0 auto;
  width: fit-content;
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb, var(--accent-light) 38%, transparent);
  border-radius: 999px;
  color: var(--accent-light);
  background: color-mix(in srgb, var(--accent-light) 7%, transparent);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
}

.swap-inline-action:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

.swap-thumbnail-option {
  position: relative;
  display: none;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
  padding: 9px 11px;
  border: 1px solid var(--glass-08);
  border-radius: 11px;
  background: var(--glass-03);
  cursor: pointer;
}

[data-swap-state="ready"] .swap-thumbnail-option,
[data-swap-state="swapping"] .swap-thumbnail-option {
  display: flex;
}

.swap-thumbnail-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.swap-thumbnail-title {
  color: var(--tg-text);
  font-size: 12px;
  font-weight: 600;
}

.swap-thumbnail-hint {
  color: var(--tg-hint);
  font-size: 10.5px;
}

.swap-thumbnail-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.swap-thumbnail-toggle {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--glass-10);
  border-radius: 999px;
  background: var(--glass-08);
  transition:
    border-color 0.18s ease,
    background 0.18s ease;
}

.swap-thumbnail-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tg-hint);
  transition:
    transform 0.18s ease,
    background 0.18s ease;
}

.swap-thumbnail-input:checked + .swap-thumbnail-toggle {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

.swap-thumbnail-input:checked + .swap-thumbnail-toggle::after {
  transform: translateX(16px);
  background: var(--accent-light);
}

.swap-thumbnail-input:focus-visible + .swap-thumbnail-toggle {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

[data-swap-state="swapping"] .swap-thumbnail-option {
  cursor: default;
  opacity: 0.65;
}

.swap-reset-btn {
  width: 100%;
  margin-top: 10px;
  justify-content: center;
  background: var(--glass-06);
  color: var(--tg-text);
  border: 1px solid var(--glass-10);
  box-shadow: none;
}

[data-swap-state="swapping"] .swap-inline-action,
[data-swap-state="success"] .swap-inline-action {
  pointer-events: none;
  opacity: 0.45;
}

.preview-seek-controls {
  position: absolute;
  z-index: 2;
  right: 7px;
  bottom: 6px;
  left: 7px;
  display: none;
  padding: 15px 2px 1px;
  color: white;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.74) 52%);
}

.preview-seek-range {
  --preview-progress: 0%;
  display: block;
  width: 100%;
  height: 16px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

.preview-seek-range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    white 0 var(--preview-progress),
    rgba(255, 255, 255, 0.36) var(--preview-progress) 100%
  );
}

.preview-seek-range::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border: 0;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: white;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

.preview-seek-range::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.36);
}

.preview-seek-range::-moz-range-progress {
  height: 3px;
  border-radius: 3px;
  background: white;
}

.preview-seek-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

.preview-seek-time {
  display: flex;
  justify-content: space-between;
  margin-top: -1px;
  font-size: 8.5px;
  font-weight: 650;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.search-source-badge {
  position: relative;
}

.search-source-spinner {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 9px;
  height: 9px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 0.15s ease;
}

.search-source-spinner.is-active {
  visibility: visible;
  opacity: 0.75;
  animation: searchSourceSpin 0.75s linear infinite;
}

@keyframes searchSourceSpin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

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

/* Compact statistics dashboard */
.stats-dashboard {
  height: 100%;
  min-height: 0;
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.stats-dashboard-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1px 2px 0;
}

.stats-dashboard-title {
  font-size: 18px;
}

.stats-dashboard-subtitle {
  margin-top: 2px;
  color: var(--tg-hint);
  font-size: 10.5px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.stat-item {
  --stat-color: var(--accent-light);
  min-height: 66px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 9px;
  align-content: center;
  position: relative;
  overflow: hidden;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--stat-color) 12%, var(--glass-05));
  border-radius: 13px;
  background: color-mix(in srgb, var(--stat-color) 4%, var(--glass-015));
}

.stat-icon {
  grid-row: 1 / span 2;
  align-self: center;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: var(--stat-color);
  background: color-mix(in srgb, var(--stat-color) 13%, transparent);
}

.stat-label {
  align-self: end;
  min-width: 0;
  color: var(--tg-hint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
}

.stat-value {
  align-self: start;
  min-width: 0;
  overflow: hidden;
  color: var(--tg-text);
  font-family: var(--font-outfit);
  font-size: 19px;
  font-weight: 750;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-storage-value {
  font-size: 16px;
}

.stat-subtext {
  grid-column: 2;
  margin-top: 1px;
  overflow: hidden;
  color: var(--tg-hint);
  font-size: 8px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-error-value,
.stats-chart-error {
  color: var(--error);
}

.stats-insights {
  flex: 1 1 auto;
  min-height: 148px;
  max-height: 190px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stats-chart-card {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px;
  border: 1px solid var(--glass-06);
  border-radius: 14px;
  background: linear-gradient(155deg, var(--glass-04), var(--glass-015));
  box-shadow: inset 0 1px 0 var(--glass-04);
}

.stats-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--accent-light);
}

.stats-chart-header h2 {
  color: var(--tg-text);
  font-family: var(--font-outfit);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
}

.stats-chart-header span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--tg-hint);
  font-size: 8px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-ranking-chart {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: space-between;
  gap: 5px;
}

.stats-ranking-row {
  min-width: 0;
}

.stats-ranking-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
  color: var(--tg-hint);
  font-size: 8.5px;
  line-height: 1.25;
}

.stats-ranking-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-ranking-meta strong {
  flex: 0 0 auto;
  color: var(--tg-text);
  font-size: 8px;
}

.stats-ranking-track {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--glass-05);
}

.stats-ranking-track span {
  display: block;
  width: var(--bar);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  box-shadow: 0 0 9px var(--accent-light-glow);
}

.stats-activity-chart {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: end;
  gap: 3px;
}

.stats-activity-day {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  align-items: end;
  justify-items: center;
  gap: 2px;
}

.stats-activity-bar-wrap {
  width: 100%;
  height: 100%;
  min-height: 34px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  border-radius: 5px;
  background: linear-gradient(to top, var(--glass-03), transparent);
}

.stats-activity-bar-wrap span {
  width: min(10px, 72%);
  height: max(3px, var(--bar));
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(to top, var(--accent), var(--accent-light));
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent-light) 22%, transparent);
}

.stats-activity-day strong {
  color: var(--tg-text);
  font-size: 7.5px;
  line-height: 1;
}

.stats-activity-day small {
  color: var(--tg-hint);
  font-size: 7px;
  font-weight: 650;
  line-height: 1;
}

.stats-chart-empty {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  color: var(--tg-hint);
  font-size: 9px;
  text-align: center;
}

@media (max-width: 350px) {
  .stats-dashboard {
    gap: 8px;
  }

  .stat-item {
    grid-template-columns: 26px minmax(0, 1fr);
    column-gap: 7px;
    padding: 8px;
  }

  .stat-icon {
    width: 26px;
    height: 26px;
  }

  .stats-chart-card {
    padding: 8px;
  }
}

@media (max-height: 650px) {
  .stats-dashboard-subtitle {
    display: none;
  }

  .stats-grid {
    gap: 6px;
  }

  .stat-item {
    min-height: 58px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .stats-insights {
    min-height: 132px;
  }
}

/* Recently Snatched Shelf */
.recent-list {
  display: block;
}

.recent-item {
  background: var(--glass-015);
  border: 1px solid var(--glass-04);
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    opacity 0.2s ease;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.track-item {
  background: var(--glass-015);
  border: 1px solid var(--glass-04);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    opacity 0.2s ease;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

@media (hover: hover) {
  .recent-item:hover {
    background: var(--glass-03);
    border-color: var(--glass-08);
  }
}

.recent-item:active {
  background: var(--glass-03);
  border-color: var(--glass-08);
}

.recent-music-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--glass-04);
  border: 1.5px dashed var(--glass-10);
  color: var(--tg-hint);
  flex-shrink: 0;
  overflow: hidden;
}

.recent-item:first-child .recent-music-icon {
  border-color: var(--accent-light);
  background: rgba(247, 37, 133, 0.08);
  color: var(--accent-light);
}

.recent-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.recent-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-artist {
  font-size: 11px;
  color: var(--tg-hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.recent-time {
  font-size: 10.5px;
  color: var(--tg-hint);
  text-align: right;
  white-space: nowrap;
  align-self: center;
}

/* Navigation Tab Bar */
.tab-bar {
  position: fixed;
  top: calc(var(--tg-vh, 100vh) - 80px);
  left: 0;
  width: 100%;
  height: 100vh;
  transition: top 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  background: var(--tab-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-10);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 10px 0 25px 0; /* extra padding for iOS bottom bar */
  z-index: 100;
}

.tab-item {
  background: none;
  border: none;
  color: var(--tg-hint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: var(--font-outfit);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.3s ease;
  flex: 1;
}

.tab-item svg {
  transition:
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    color 0.3s ease;
}

.tab-item.active {
  color: var(--tg-text);
}

.tab-item:focus-visible {
  background: var(--glass-06);
  border-radius: 10px;
}

.tab-item.active svg {
  color: var(--accent-light);
  transform: scale(1.15) translateY(-2px);
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}

.tab-content.active {
  display: block;
}

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

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

.fade-out {
  animation: fadeOut 0.3s ease forwards !important;
}

/* Skeleton Shimmer Loaders */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--glass-02) 25%,
    var(--glass-06) 50%,
    var(--glass-02) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-value {
  width: 60%;
  height: 22px;
  margin-top: 3px;
}

.skeleton-text {
  width: 80%;
  height: 14px;
  margin-bottom: 4px;
}

.skeleton-title {
  width: 70%;
  height: 15px;
}

.skeleton-subtitle {
  width: 45%;
  height: 11px;
  margin-top: 4px;
}

.skeleton-time {
  width: 50px;
  height: 11px;
}

.tab-loading,
.tab-load-error {
  padding: 50px 20px;
  color: var(--tg-hint);
  text-align: center;
}

.tab-load-error {
  color: var(--error);
}
