/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  /* --- Spacing scale --- */
  --space-2xs: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;

  /* --- Border radius --- */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-pill: 9999px;

  /* --- Z-index scale --- */
  --z-base:     1;
  --z-content:  10;
  --z-sticky:   20;
  --z-dropdown: 30;
  --z-overlay:  40;
  --z-modal:    50;

  /* --- Typography --- */
  --font-display: 'Figtree', system-ui, sans-serif;
  --font-body:    'Figtree', system-ui, sans-serif;

  --fs-display: clamp(1.5rem,  1.2rem + 1.5vw, 2.25rem);
  --fs-h1:      clamp(1.25rem, 1rem   + 1.2vw, 1.875rem);
  --fs-h2:      clamp(1.1rem,  0.95rem + 0.8vw, 1.5rem);
  --fs-h3:      clamp(1rem,    0.9rem  + 0.5vw, 1.25rem);
  --fs-body:    clamp(0.9375rem, 0.875rem + 0.25vw, 1.0625rem);
  --fs-sm:      clamp(0.8125rem, 0.775rem + 0.15vw, 0.9rem);
  --fs-xs:      0.75rem;

  --lh-heading: 1.2;
  --lh-body:    1.6;

  /* --- Transitions --- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 350ms;
}

/* ---- Dark theme (default) ---- */
:root,
[data-theme="dark"] {
  --color-bg:           #0c0c10;
  --color-surface:      #141418;
  --color-surface-2:    #1c1c22;
  --color-surface-3:    #26262e;
  --color-surface-hover:#2e2e38;
  --color-border:       rgba(255,255,255,0.07);
  --color-border-strong:rgba(255,255,255,0.14);

  --color-text:         #eeeef2;
  --color-text-muted:   #9898a8;
  --color-text-subtle:  #60606e;

  --color-accent:       #22d36b;
  --color-accent-dim:   #1aaa55;
  --color-accent-soft:  rgba(34, 211, 107, 0.12);
  --color-accent-text:  #0c0c10;

  --color-danger:       #f25858;
  --color-danger-soft:  rgba(242, 88, 88, 0.12);

  --color-new:          #22d36b;
  --color-up:           #4ca8ff;
  --color-down:         #f25858;

  --color-skeleton-base:rgba(255,255,255,0.05);
  --color-skeleton-shine:rgba(255,255,255,0.10);
}

/* ---- Light theme ---- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --color-bg:           #f4f4f7;
    --color-surface:      #ffffff;
    --color-surface-2:    #f0f0f4;
    --color-surface-3:    #e6e6ec;
    --color-surface-hover:#e0e0e8;
    --color-border:       rgba(0,0,0,0.07);
    --color-border-strong:rgba(0,0,0,0.14);

    --color-text:         #0e0e14;
    --color-text-muted:   #505060;
    --color-text-subtle:  #909098;

    --color-accent:       #16a34a;
    --color-accent-dim:   #15803d;
    --color-accent-soft:  rgba(22, 163, 74, 0.10);
    --color-accent-text:  #ffffff;

    --color-danger:       #dc2626;
    --color-danger-soft:  rgba(220, 38, 38, 0.10);

    --color-new:          #16a34a;
    --color-up:           #2563eb;
    --color-down:         #dc2626;

    --color-skeleton-base: rgba(0,0,0,0.06);
    --color-skeleton-shine:rgba(0,0,0,0.10);
  }
}

[data-theme="light"] {
  --color-bg:           #f4f4f7;
  --color-surface:      #ffffff;
  --color-surface-2:    #f0f0f4;
  --color-surface-3:    #e6e6ec;
  --color-surface-hover:#e0e0e8;
  --color-border:       rgba(0,0,0,0.07);
  --color-border-strong:rgba(0,0,0,0.14);

  --color-text:         #0e0e14;
  --color-text-muted:   #505060;
  --color-text-subtle:  #909098;

  --color-accent:       #16a34a;
  --color-accent-dim:   #15803d;
  --color-accent-soft:  rgba(22, 163, 74, 0.10);
  --color-accent-text:  #ffffff;

  --color-danger:       #dc2626;
  --color-danger-soft:  rgba(220, 38, 38, 0.10);

  --color-new:          #16a34a;
  --color-up:           #2563eb;
  --color-down:         #dc2626;

  --color-skeleton-base: rgba(0,0,0,0.06);
  --color-skeleton-shine:rgba(0,0,0,0.10);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  background-color: var(--color-bg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Prevent scroll during drag-over overlay */
  overflow-x: hidden;
}

/* ============================================================
   APP SHELL
   ============================================================ */

.main-block {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 1024px;
  margin: 0 auto;
  background-color: var(--color-bg);
  position: relative;
  overflow: hidden;
}

/* ============================================================
   HEADER TITLE (branding bar)
   ============================================================ */

.header-title {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

/* Accent dot after title */
.header-title::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: var(--color-accent);
  border-radius: 50%;
  margin-left: var(--space-xs);
  vertical-align: middle;
  position: relative;
  top: -2px;
}

@media (max-width: 639px) {
  .header-title {
    display: none;
  }
}

/* ============================================================
   HEADER CONTROLS BAR
   ============================================================ */

.header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: grid;
  grid-template-columns: 1fr auto auto 1fr;
  align-items: stretch;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: 56px;
  flex-shrink: 0;
  will-change: transform; /* compositor layer for sticky */
}

/* When header-title is visible, header sticks below it */
@media (min-width: 640px) {
  .header-title + .header {
    top: 52px;
  }
}

/* ============================================================
   LATEST CHECKBOX (left column of header grid)
   ============================================================ */

.pl-latest {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0 var(--space-sm);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-fast) var(--ease-out);
}

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

.pl-latest input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border-strong);
  border-radius: 4px;
  background-color: var(--color-surface-2);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.pl-latest input[type="checkbox"]:checked {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}

.pl-latest input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: 2px solid var(--color-accent-text);
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.pl-latest input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ============================================================
   DATE / YEAR CONTROLS (center of header)
   ============================================================ */

.date-block {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: var(--space-xs);
  min-width: 0;
}

input.pl_date,
#pl_year {
  background-color: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  height: 40px;
  padding: 0 var(--space-xs);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
  /* Prevent layout-shift by pre-declaring size */
  min-width: 140px;
}

select.pl-mode {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  background-color: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  height: 40px;
  padding: 0 var(--space-xs);
  outline: none;
  cursor: pointer;
  min-width: 90px;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}

select.pl-mode:focus {
  border-color: var(--color-accent);
  background-color: var(--color-accent-soft);
}

select.pl-mode:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

input.pl_date:focus,
#pl_year:focus {
  border-color: var(--color-accent);
  background-color: var(--color-accent-soft);
}

input.pl_date:focus-visible,
#pl_year:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Calendar picker icon tint */
input.pl_date::-webkit-calendar-picker-indicator {
  opacity: 0.5;
  filter: invert(1);
  cursor: pointer;
}

@media (prefers-color-scheme: light) {
  input.pl_date::-webkit-calendar-picker-indicator {
    filter: none;
  }
}

/* ============================================================
   UPLOAD / DOWNLOAD ICON BUTTONS (top-right cluster)
   ============================================================ */

.updown-items {
  grid-column: 4;
  grid-row: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-self: end;
  padding-right: var(--space-xs);
  gap: var(--space-2xs);
}

/* ============================================================
   MENU ITEM — shared interactive base
   ============================================================ */

.menu-item {
  cursor: pointer;
  -webkit-touch-callout: none;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}

.menu-item:active {
  opacity: 0.7;
}

/* ============================================================
   NAV ARROWS (prev / next)
   ============================================================ */

.pl-prev,
.pl-next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: transparent;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  /* CSS-only chevron via clip-path-safe border trick */
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
}

.pl-prev {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239898a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'/%3E%3C/svg%3E");
}

.pl-next {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239898a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");
}

.pl-prev:hover,
.pl-next:hover {
  background-color: var(--color-surface-2);
  color: var(--color-text);
}

.pl-prev:focus-visible,
.pl-next:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

@media (max-width: 639px) {
  .pl-prev,
  .pl-next {
    display: none;
  }
}

/* ============================================================
   UPLOAD / DOWNLOAD ICON BUTTONS
   ============================================================ */

.pl-upload,
.pl-download {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 20px 20px;
  color: var(--color-text-muted);
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.pl-upload {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239898a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E");
}

.pl-download {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239898a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
}

.pl-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 20px 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f25858' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6'/%3E%3Cpath d='M10 11v6'/%3E%3Cpath d='M14 11v6'/%3E%3Cpath d='M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2'/%3E%3C/svg%3E");
  transition: background-color var(--dur-fast) var(--ease-out);
}

.pl-delete:hover {
  background-color: var(--color-danger-soft);
}

.pl-delete:focus-visible {
  outline: 2px solid var(--color-danger);
  outline-offset: 2px;
}

.pl-upload:hover,
.pl-download:hover {
  background-color: var(--color-surface-2);
}

.pl-upload:focus-visible,
.pl-download:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

@media (max-width: 639px) {
  .pl-upload {
    display: none;
  }
}

/* ============================================================
   PLAYLIST CONTENT AREA
   ============================================================ */

.list {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-md) var(--space-md) var(--space-2xl);
  z-index: var(--z-base);
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   SWIPE ANIMATION (playlist-content lateral moves)
   ============================================================ */

#playlist-content {
  position: relative;
  transform: translateZ(0); /* own compositor layer */
  will-change: transform;
}

#playlist-content.moveleft {
  transform: translateX(100vw) translateZ(0);
  transition: transform var(--dur-slow) var(--ease-out);
}

#playlist-content.moveright {
  transform: translateX(-100vw) translateZ(0);
  transition: transform var(--dur-slow) var(--ease-out);
}

/* ============================================================
   LIST SECTION HEADER (A-List / B-List / C-List)
   ============================================================ */

.list-title {
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  padding: var(--space-lg) 0 var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

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

/* Accent stripe for A-List */
.list-title:first-child::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--color-accent);
  border-radius: var(--radius-pill);
}

/* ============================================================
   SONG CARD
   ============================================================ */

.list-item {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2xs);
  overflow: hidden;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  /* Prevent CLS — minimum card height */
  min-height: 60px;
  will-change: transform;
  transform: translateZ(0);

  /* Entry animation */
  animation: card-in var(--dur-base) var(--ease-out) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px) translateZ(0);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateZ(0);
  }
}

.list-item:hover {
  background-color: var(--color-surface-2);
  border-color: var(--color-border-strong);
  transform: translateY(-1px) translateZ(0);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* ============================================================
   STATUS BADGE (left column — pl-new / pl-up / pl-down)
   ============================================================ */

.item-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 52px;
  background-color: var(--color-surface-2);
  border-right: 1px solid var(--color-border);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text-muted);
  /* Prevent CLS */
  min-height: 68px;
}

/* New track — star/sparkle */
.item-info.pl-new {
  background-color: var(--color-accent-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2322d36b'%3E%3Cpath d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/%3E%3C/svg%3E");
  border-right-color: var(--color-accent);
}

/* Moving up — chevron up */
.item-info.pl-up {
  background-color: rgba(76, 168, 255, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234ca8ff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'/%3E%3C/svg%3E");
  border-right-color: #4ca8ff;
}

/* Moving down — chevron down */
.item-info.pl-down {
  background-color: rgba(242, 88, 88, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f25858' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  border-right-color: #f25858;
}

/* Ranked number (top100 mode) */
.item-info.top100 {
  font-size: var(--fs-h3);
  font-weight: 700;
  color: var(--color-text);
  background-image: none;
  background-color: var(--color-surface-2);
  letter-spacing: -0.02em;
}

/* Score totals column (right side) */
.item-info.total {
  width: 64px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  background-image: none;
  background-color: transparent;
  border-right: none;
  border-left: 1px solid var(--color-border);
}

/* Light mode adjustments for indicator icons */
@media (prefers-color-scheme: light) {
  .item-info.pl-new {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2316a34a'%3E%3Cpath d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/%3E%3C/svg%3E");
    border-right-color: var(--color-accent);
    background-color: var(--color-accent-soft);
  }
  .item-info.pl-up {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'/%3E%3C/svg%3E");
    border-right-color: #2563eb;
    background-color: rgba(37, 99, 235, 0.08);
  }
  .item-info.pl-down {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    border-right-color: #dc2626;
    background-color: rgba(220, 38, 38, 0.08);
  }
}

/* ============================================================
   SONG DETAILS (main body of card)
   ============================================================ */

.item-main {
  flex: 1;
  min-width: 0; /* critical — prevents flex overflow */
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-xs) var(--space-md);
  text-align: left;
}

.song {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 600;
  color: var(--color-accent);
  line-height: var(--lh-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.artist {
  font-size: var(--fs-body);
  font-weight: 400;
  color: var(--color-text-muted);
  line-height: var(--lh-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   LOADING STATE — skeleton shimmer
   ============================================================ */

@keyframes shimmer {
  from { background-position: -400px 0; }
  to   { background-position:  400px 0; }
}

.pl-loading {
  /* Hide the background gif — we use CSS skeletons instead */
  background-image: none !important;
  min-height: 400px;
  padding-top: var(--space-lg);
}

/* Generate skeleton card rows via repeated gradient */
.pl-loading::before {
  content: '';
  display: block;
  border-radius: var(--radius-md);
  height: 68px;
  margin-bottom: var(--space-xs);
  background: linear-gradient(
    90deg,
    var(--color-skeleton-base) 25%,
    var(--color-skeleton-shine) 50%,
    var(--color-skeleton-base) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.pl-loading::after {
  content: '';
  display: block;
  border-radius: var(--radius-md);
  height: 68px;
  margin-bottom: var(--space-xs);
  background: linear-gradient(
    90deg,
    var(--color-skeleton-base) 25%,
    var(--color-skeleton-shine) 50%,
    var(--color-skeleton-base) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  animation-delay: 0.15s;
}

/* Hide real content while loading (list-items are inside .pl-loading) */
.pl-loading .list-item,
.pl-loading .list-title,
.pl-loading .countdown-block {
  display: none;
}

/* ============================================================
   DRAG-OVER OVERLAY
   ============================================================ */

.pl-dragover {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 600;
  gap: var(--space-md);
  pointer-events: none;
}

.pl-dragover::before {
  content: '';
  display: block;
  width: 64px;
  height: 64px;
  border: 3px dashed var(--color-accent);
  border-radius: var(--radius-lg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2322d36b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 28px;
}

.pl-dragover::after {
  content: 'Drop playlist to upload';
  font-size: var(--fs-body);
  color: var(--color-text-muted);
}

/* Dim everything else while dragging */
.pl-dragover-new > *:not(.pl-dragover) {
  opacity: 0.4;
  transition: opacity var(--dur-fast) var(--ease-out);
}

/* ============================================================
   COUNTDOWN BLOCK
   ============================================================ */

.countdown-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) 0 var(--space-lg);
}

.countdown-block button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 var(--space-lg);
  background-color: var(--color-accent);
  color: var(--color-accent-text);
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: var(--fs-body);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  box-shadow: 0 0 0 0 var(--color-accent-soft);
}

.countdown-block button:hover {
  background-color: var(--color-accent-dim);
  transform: translateY(-1px) translateZ(0);
  box-shadow: 0 6px 20px rgba(34, 211, 107, 0.3);
}

.countdown-block button:active {
  transform: translateY(0) translateZ(0);
  box-shadow: none;
}

.countdown-block button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* ============================================================
   UTILITY / LEGACY
   ============================================================ */

.pl-calendar {
  background-image: url('calendar-icon.png');
}

/* Bootstrap-like btn kept for any leftover markup */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 var(--space-md);
  font-size: var(--fs-body);
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.btn-success {
  background-color: #16a34a;
  color: #fff;
}

.btn-danger {
  background-color: var(--color-danger);
  color: #fff;
}

/* ============================================================
   RESPONSIVE OVERRIDES
   ============================================================ */

/* ---- Tablet (640–1024px) ---- */
@media (min-width: 640px) {
  input.pl_date,
  #pl_year {
    font-size: var(--fs-h3);
  }

  .list {
    padding: var(--space-lg) var(--space-xl) var(--space-2xl);
  }

  .header {
    height: 60px;
  }

  .item-info {
    width: 60px;
    min-height: 72px;
  }

  .item-info.total {
    width: 80px;
  }

  .item-info.top100 {
    font-size: var(--fs-h2);
  }

  .list-item {
    min-height: 64px;
  }

  .item-main {
    padding: var(--space-xs) var(--space-lg);
  }
}

/* ---- Desktop (>1024px) ---- */
@media (min-width: 1025px) {
  .main-block {
    box-shadow: 0 0 80px rgba(0,0,0,0.35);
  }

  .list {
    padding: var(--space-xl) var(--space-2xl) var(--space-2xl);
  }

  .header {
    height: 64px;
  }

  select.pl-mode {
    margin-right: var(--space-xs);
  }

  .item-info {
    width: 68px;
    min-height: 64px;
  }

  .list-item {
    min-height: 64px;
    margin-bottom: var(--space-2xs);
  }

  .item-main {
    padding: var(--space-xs) var(--space-xl);
  }

  .song {
    font-size: var(--fs-h3);
    margin-bottom: 2px;
  }

  .artist {
    font-size: var(--fs-body);
  }
}

/* ---- Touch / narrow mobile ---- */
@media (max-width: 639px) {
  .main-menu {
    min-width: 44px;
    min-height: 44px;
  }

  /* 2-row header: row 1 = Latest | mode | icons; row 2 = date/year */
  .header {
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: 48px 44px;
    height: auto;
  }

  .pl-latest {
    grid-column: 1;
    grid-row: 1;
  }

  select.pl-mode {
    grid-column: 2;
    grid-row: 1;
  }

  .updown-items {
    grid-column: 3;
    grid-row: 1;
  }

  .date-block {
    grid-column: 1 / -1;
    grid-row: 2;
    border-top: 1px solid var(--color-border);
    padding: 0 var(--space-sm);
  }

  input.pl_date,
  #pl_year {
    flex: 1;
    min-width: 0;
    font-size: var(--fs-body);
    height: 36px;
  }

  .pl-upload,
  .pl-download {
    min-width: 44px;
    min-height: 44px;
  }
}
