:root {
      --bg: #090a0d;
      --surface: #121419;
      --surface-2: #191c23;
      --surface-3: #242934;
      --text: #f5f7fb;
      --muted: #a7aebb;
      --accent: #4f83ff;
      --accent-strong: #78a3ff;
      --accent-ink: #07101f;
      --border: rgb(79 131 255 / 22%);
      --danger: #e8958e;
      --radius: 18px;
      --tap: 48px;
    }

    * { box-sizing: border-box; }

    html {
      scroll-behavior: smooth;
      background: var(--bg);
    }

    body {
      margin: 0;
      min-width: 320px;
      min-height: 100vh;
      min-height: 100dvh;
      background:
        radial-gradient(circle at 14% -8%, rgb(79 131 255 / 18%), transparent 36rem),
        linear-gradient(180deg, var(--surface) 0%, var(--bg) 38rem);
      color: var(--text);
      font-family: Georgia, "Times New Roman", serif;
      -webkit-font-smoothing: antialiased;
    }

    button,
    input,
    select {
      font: inherit;
    }

    button,
    a {
      -webkit-tap-highlight-color: transparent;
    }

    button:focus-visible,
    a:focus-visible,
    input:focus-visible,
    select:focus-visible {
      outline: 3px solid rgb(120 163 255 / 68%);
      outline-offset: 2px;
    }

    .app-shell {
      width: min(100%, 1120px);
      margin: 0 auto;
      padding: 0 14px calc(32px + env(safe-area-inset-bottom));
    }

    .hero {
      padding: calc(28px + env(safe-area-inset-top)) 4px 22px;
    }

    .eyebrow {
      margin: 0 0 8px;
      color: var(--accent);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .75rem;
      font-weight: 800;
      letter-spacing: .16em;
      text-transform: uppercase;
    }

    h1 {
      max-width: 760px;
      margin: 0;
      font-size: clamp(2rem, 10vw, 4.25rem);
      font-weight: 500;
      line-height: .98;
      letter-spacing: -.045em;
    }

    .intro {
      max-width: 760px;
      margin: 16px 0 0;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .98rem;
      line-height: 1.58;
    }

    .playlist-library {
      margin: 0 0 22px;
    }

    .playlist-library-heading {
      display: flex;
      align-items: end;
      justify-content: space-between;
      gap: 16px;
      margin-bottom: 12px;
    }

    .playlist-library-heading h2 {
      margin: 0;
      font-size: clamp(1.45rem, 5vw, 2rem);
      font-weight: 500;
    }

    .playlist-cards {
      display: grid;
      grid-auto-columns: minmax(150px, 185px);
      grid-auto-flow: column;
      gap: 12px;
      padding: 2px 2px 10px;
      overflow-x: auto;
      overscroll-behavior-inline: contain;
      scrollbar-color: var(--surface-3) transparent;
      scroll-snap-type: inline proximity;
    }

    .collection-card {
      position: relative;
      min-width: 0;
      padding: 9px;
      border: 1px solid var(--border);
      border-radius: 15px;
      background: var(--surface);
      box-shadow: 0 10px 24px rgba(0, 0, 0, .16);
      scroll-snap-align: start;
    }

    .collection-card.active {
      border-color: var(--accent-strong);
      background: linear-gradient(145deg, rgb(79 131 255 / 20%), var(--surface) 60%);
    }

    .collection-select {
      display: grid;
      width: 100%;
      padding: 0;
      border: 0;
      background: transparent;
      color: var(--text);
      text-align: left;
      cursor: pointer;
    }

    .collection-cover {
      display: grid;
      aspect-ratio: 1;
      place-items: center;
      margin-bottom: 10px;
      border-radius: 10px;
      background: linear-gradient(145deg, #23466b, #72507e);
      color: rgba(255, 255, 255, .9);
      font-family: system-ui, sans-serif;
      font-size: 3rem;
      font-weight: 800;
      box-shadow: 0 8px 18px rgba(0, 0, 0, .3);
    }

    .collection-cover-1 { background: linear-gradient(145deg, #69512e, #9a5360); }
    .collection-cover-2 { background: linear-gradient(145deg, #265e57, #415386); }
    .collection-cover-3 { background: linear-gradient(145deg, #67426e, #9c663c); }
    .collection-cover-4 { background: linear-gradient(145deg, #344c73, #477456); }

    .collection-select strong,
    .collection-select small,
    .collection-tools {
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    .collection-select strong {
      overflow: hidden;
      font-size: .93rem;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .collection-select small { margin-top: 3px; color: var(--muted); }

    .collection-tools {
      display: flex;
      gap: 10px;
      margin-top: 9px;
    }

    .collection-tools button {
      padding: 2px 0;
      border: 0;
      background: transparent;
      color: var(--muted);
      font-size: .72rem;
      cursor: pointer;
    }

    .collection-tools button:hover { color: var(--text); }

    .controls-wrap {
      margin: 0 -14px 18px;
      padding: 10px 14px 12px;
      background: linear-gradient(180deg, rgb(9 10 13 / 98%), rgb(9 10 13 / 92%));
      border-bottom: 1px solid var(--border);
      backdrop-filter: blur(16px);
    }

    .controls {
      display: grid;
      grid-template-columns: 1fr;
      gap: 9px;
      width: min(100%, 1092px);
      margin: 0 auto;
    }

    .field {
      position: relative;
    }

    .field svg {
      position: absolute;
      top: 50%;
      left: 15px;
      width: 19px;
      height: 19px;
      color: var(--muted);
      transform: translateY(-50%);
      pointer-events: none;
    }

    .search,
    .select {
      width: 100%;
      min-height: var(--tap);
      border: 1px solid var(--border);
      border-radius: 14px;
      background: var(--surface);
      color: var(--text);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: 1rem;
    }

    .search {
      padding: 0 14px 0 45px;
    }

    .select {
      padding: 0 40px 0 14px;
      appearance: none;
      background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
      background-position:
        calc(100% - 20px) 21px,
        calc(100% - 15px) 21px;
      background-size: 5px 5px, 5px 5px;
      background-repeat: no-repeat;
    }

    .summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      min-height: 34px;
      padding: 0 2px;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .86rem;
    }

    .reset-button {
      border: 0;
      background: transparent;
      color: var(--accent-strong);
      font-family: inherit;
      font-weight: 700;
      cursor: pointer;
    }

    .pieces {
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
    }

    .catalog-actions {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 9px;
      margin: 0 0 14px;
    }

    .catalog-actions .desktop-link-edit,
    .desktop-list-heading,
    .quick-video-editor,
    .piece-details-unavailable { display: none; }

    .pagination {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: center;
      gap: 8px;
      margin: 20px 0 4px;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    .pagination[hidden] { display: none; }

    .pagination-button {
      min-height: 42px;
      padding: 8px 12px;
      border: 1px solid var(--border);
      border-radius: 11px;
      background: var(--surface-2);
      color: var(--text);
      font-size: .82rem;
      font-weight: 750;
      cursor: pointer;
    }

    .pagination-button:disabled {
      cursor: not-allowed;
      opacity: .38;
    }

    .pagination-jump {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      color: var(--muted);
      font-size: .84rem;
      white-space: nowrap;
    }

    .pagination-input {
      width: 68px;
      min-height: 42px;
      padding: 7px 8px;
      border: 1px solid var(--border);
      border-radius: 11px;
      background: var(--surface-2);
      color: var(--text);
      text-align: center;
    }

    @media (max-width: 480px) {
      .pagination-jump {
        order: -1;
        flex-basis: 100%;
      }
    }

    .optional {
      color: var(--muted);
      font-weight: 400;
    }

    .membership-list {
      display: grid;
      gap: 8px;
      max-height: min(48vh, 420px);
      overflow-y: auto;
    }

    .membership-option {
      display: flex;
      align-items: center;
      gap: 11px;
      padding: 11px;
      border: 1px solid var(--border);
      border-radius: 11px;
      background: var(--surface-2);
      cursor: pointer;
    }

    .membership-option input { width: 20px; height: 20px; accent-color: var(--accent); }
    .membership-option span { display: grid; gap: 2px; }
    .membership-option small { color: var(--muted); }

    .piece-details {
      margin-top: 8px;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .78rem;
    }

    .piece-details summary,
    .metadata-fields summary {
      color: var(--accent-strong);
      cursor: pointer;
      font-weight: 750;
    }

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

    .piece-metadata div { min-width: 0; }
    .piece-metadata dt { font-weight: 750; }
    .piece-metadata dd {
      overflow-wrap: anywhere;
      margin: 2px 0 0;
      color: var(--text);
    }

    .piece {
      position: relative;
      overflow: hidden;
      padding: 11px;
      border: 1px solid var(--border);
      border-radius: 12px;
      background: var(--surface);
      box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
    }

    .piece-head {
      display: grid;
      grid-template-columns: 38px minmax(0, 1fr);
      gap: 9px;
      align-items: center;
    }

    .rank {
      display: grid;
      place-items: center;
      width: 38px;
      height: 38px;
      border: 0;
      border-radius: 8px;
      color: #fff;
      background: linear-gradient(145deg, #315f8d, #755482);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .72rem;
      font-weight: 800;
    }

    .title {
      margin: 0;
      font-size: 1.02rem;
      font-weight: 700;
      line-height: 1.15;
    }

    .composer {
      margin: 3px 0 0;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .75rem;
      font-weight: 600;
      line-height: 1.3;
    }

    .genre {
      display: inline-flex;
      margin: 8px 0 0 47px;
      padding: 4px 7px;
      border: 1px solid rgba(255, 255, 255, .07);
      border-radius: 999px;
      background: rgba(255, 255, 255, .035);
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .65rem;
      line-height: 1;
    }

    .genre.empty { display: none; }

    .actions {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 5px;
      margin-top: 10px;
    }

    .actions .button {
      min-height: 40px;
      padding: 0;
      border-radius: 9px;
    }

    .actions .button-label { display: none; }

    .button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 9px;
      min-height: var(--tap);
      padding: 10px 14px;
      border: 1px solid transparent;
      border-radius: 13px;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .91rem;
      font-weight: 800;
      line-height: 1;
      text-decoration: none;
      cursor: pointer;
      transition: transform .14s ease, background .14s ease, border-color .14s ease;
    }

    .button:active {
      transform: scale(.985);
    }

    .button:disabled {
      cursor: not-allowed;
      opacity: .38;
      transform: none;
    }

    .button svg {
      width: 18px;
      height: 18px;
      flex: 0 0 auto;
    }

    .button-primary {
      background: var(--accent);
      color: var(--accent-ink);
    }

    .button-secondary {
      border-color: var(--border);
      background: var(--surface-2);
      color: var(--text);
    }

    .button-danger {
      border-color: rgba(232, 149, 142, .25);
      background: transparent;
      color: var(--danger);
    }

    .empty {
      display: none;
      padding: 48px 22px;
      border: 1px dashed var(--border);
      border-radius: var(--radius);
      color: var(--muted);
      text-align: center;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      line-height: 1.55;
    }

    .empty.visible { display: block; }

    .help {
      margin: 8px 0 0;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .78rem;
      line-height: 1.4;
    }

    .help { color: var(--muted); }

    .footer-note {
      max-width: 760px;
      margin: 28px auto 0;
      color: var(--muted);
      text-align: center;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .78rem;
      line-height: 1.55;
    }

    .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;
    }

    @media (min-width: 560px) {
      .actions { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    }

    @media (min-width: 720px) {
      .app-shell {
        padding-inline: 24px;
      }

      .controls-wrap {
        margin-inline: -24px;
        padding-inline: 24px;
      }

      .controls {
        grid-template-columns: minmax(0, 1.55fr) minmax(210px, .75fr);
      }

      .summary {
        grid-column: 1 / -1;
      }

      .pieces {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 15px;
      }

    }

    @media (min-width: 1040px) {
      .pieces {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
    }

    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
      }
    }

    .sync-status {
      min-height: 28px;
      padding: 2px;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .78rem;
      line-height: 1.4;
    }

    .sync-status.success { color: var(--accent-strong); }
    .sync-status.error { color: var(--danger); }
    .sync-status.working { color: var(--accent-strong); }


    /* Drawer playlist: modale a schermo intero su mobile, sidebar fissa su desktop. */
    body.playlist-menu-open { overflow: hidden; }
    body.playlist-menu-open.playlist-browser-drag { overflow-y: auto; }

    .playlist-menu-trigger {
      position: fixed;
      z-index: 80;
      right: max(14px, env(safe-area-inset-right));
      bottom: calc(14px + env(safe-area-inset-bottom));
      display: inline-flex;
      align-items: center;
      gap: 10px;
      min-height: 48px;
      padding: 10px 14px 10px 17px;
      border: 1px solid var(--border);
      border-radius: 999px;
      background: var(--accent);
      color: var(--accent-ink);
      box-shadow: 0 12px 32px rgba(0, 0, 0, .42);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .84rem;
      font-weight: 850;
      cursor: pointer;
    }

    .playlist-menu-trigger:disabled {
      opacity: .48;
      cursor: not-allowed;
    }

    .playlist-trigger-count {
      display: grid;
      place-items: center;
      min-width: 26px;
      height: 26px;
      padding: 0 6px;
      border-radius: 999px;
      background: rgba(0, 0, 0, .2);
      font-size: .72rem;
    }

    .playlist-backdrop {
      position: fixed;
      z-index: 110;
      inset: 0;
      background: rgba(0, 0, 0, .68);
      backdrop-filter: blur(5px);
    }

    .playlist-backdrop[hidden] { display: none; }

    .playlist {
      position: fixed;
      z-index: 120;
      top: 0;
      right: 0;
      display: flex;
      flex-direction: column;
      width: 100%;
      height: 100vh;
      height: 100dvh;
      overflow: hidden;
      border-left: 1px solid var(--border);
      background:
        linear-gradient(155deg, rgb(79 131 255 / 10%), transparent 22rem),
        var(--surface);
      box-shadow: -18px 0 48px rgba(0, 0, 0, .38);
      visibility: hidden;
      transform: translateX(100%);
      transition: transform .22s ease, visibility 0s linear .22s;
    }

    .playlist.open {
      visibility: visible;
      transform: translateX(0);
      transition-delay: 0s;
    }

    .playlist-heading {
      position: relative;
      display: flex;
      flex: 0 0 auto;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      min-height: 70px;
      padding: calc(12px + env(safe-area-inset-top)) 14px 10px;
      border-bottom: 1px solid var(--border);
      touch-action: pan-y;
    }

    .playlist-heading::before {
      position: absolute;
      top: calc(5px + env(safe-area-inset-top));
      left: 50%;
      width: 38px;
      height: 4px;
      border-radius: 999px;
      background: rgba(255, 255, 255, .26);
      content: "";
      transform: translateX(-50%);
    }

    .playlist-kicker {
      margin: 0 0 3px;
      color: var(--accent);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .62rem;
      font-weight: 850;
      letter-spacing: .13em;
      text-transform: uppercase;
    }

    .playlist-heading h2 {
      margin: 0;
      overflow: hidden;
      font-size: 1.42rem;
      font-weight: 500;
      line-height: 1;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .playlist-heading > div:first-child { min-width: 0; }

    .playlist-heading-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .playlist-count {
      flex: 0 0 auto;
      padding: 5px 8px;
      border: 1px solid var(--border);
      border-radius: 999px;
      color: var(--muted);
      background: rgba(0, 0, 0, .16);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .68rem;
      font-weight: 750;
    }

    .playlist-view-toggle {
      min-height: 34px;
      padding: 5px 10px;
      border: 1px solid var(--border);
      border-radius: 999px;
      background: var(--surface-2);
      color: var(--text);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .7rem;
      font-weight: 800;
      cursor: pointer;
    }

    .playlist-view-toggle[aria-pressed="true"] {
      border-color: var(--accent);
      color: var(--accent-strong);
    }

    .playlist-view-toggle:disabled {
      cursor: not-allowed;
      opacity: .38;
    }

    .playlist-close {
      display: grid;
      place-items: center;
      width: 42px;
      height: 42px;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 50%;
      background: var(--surface-2);
      color: var(--text);
      font-family: system-ui, sans-serif;
      font-size: 1.45rem;
      line-height: 1;
      cursor: pointer;
    }

    .playlist-empty {
      margin: 16px;
      padding: 20px 16px;
      border: 1px dashed var(--border);
      border-radius: 14px;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .82rem;
      line-height: 1.5;
      text-align: center;
    }

    #playlist-content {
      display: flex;
      flex: 1 1 auto;
      flex-direction: column;
      min-height: 0;
    }

    #playlist-content[hidden] { display: none; }

    .playlist-video-area {
      flex: 0 0 auto;
      padding: 10px 12px;
      border-bottom: 1px solid rgba(255, 255, 255, .06);
    }

    .playlist-video-area.queue-hidden {
      height: 0;
      padding: 0;
      overflow: hidden;
      border-bottom: 0;
    }

    .playlist-video-toggle {
      width: 100%;
      min-height: 38px;
      border: 1px solid rgba(255, 255, 255, .18);
      border-radius: 999px;
      background: rgba(255, 255, 255, .035);
      color: var(--text);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .78rem;
      font-weight: 800;
      cursor: pointer;
      transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
    }

    .playlist-video-toggle:disabled {
      cursor: not-allowed;
      opacity: .38;
    }

    .playlist-video-shell {
      position: fixed;
      top: 0;
      left: -200vw;
      overflow: hidden;
      width: 480px;
      height: 270px;
      border: 1px solid var(--border);
      border-radius: 12px;
      background: var(--bg);
      clip: rect(0 0 0 0);
      clip-path: inset(50%);
      pointer-events: none;
    }

    .playlist-video-shell.visible {
      position: relative;
      inset: auto;
      width: 100%;
      height: auto;
      min-height: 200px;
      aspect-ratio: 16 / 9;
      margin-top: 9px;
      clip: auto;
      clip-path: none;
      pointer-events: auto;
    }

    .playlist-player-mount,
    .playlist-player-mount iframe {
      width: 100%;
      height: 100%;
      border: 0;
    }

    .playlist-tracks {
      flex: 1 1 auto;
      min-height: 0;
      padding: 0;
      margin: 0;
      overflow-y: auto;
      overscroll-behavior: contain;
      list-style: none;
      scrollbar-color: var(--accent) transparent;
    }

    .playlist-track-item + .playlist-track-item {
      border-top: 1px solid rgba(255, 255, 255, .055);
    }

    .playlist-track {
      display: grid;
      grid-template-columns: 26px minmax(0, 1fr) auto;
      gap: 8px;
      align-items: center;
      width: 100%;
      min-height: 47px;
      padding: 5px 10px;
      border: 0;
      background: transparent;
      color: var(--text);
      text-align: left;
      cursor: pointer;
    }

    .playlist-track:hover { background: rgba(255, 255, 255, .035); }

    .playlist-track-static {
      cursor: default;
    }

    .playlist-track-static:not(.active):hover { background: transparent; }

    .playlist-queue-current {
      padding: 10px 10px 12px;
      background: var(--surface);
    }

    .playlist-queue-current .playlist-track {
      border: 1px solid var(--border);
      border-radius: 12px;
    }

    .playlist-queue-heading {
      padding: 14px 12px 7px;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .68rem;
      font-weight: 800;
      letter-spacing: .08em;
      list-style: none;
      text-transform: uppercase;
    }

    .playlist-track.active {
      background: rgb(79 131 255 / 13%);
      box-shadow: inset 3px 0 0 var(--accent);
    }

    .playlist-track-rank {
      display: grid;
      place-items: center;
      width: 25px;
      height: 25px;
      border: 1px solid var(--border);
      border-radius: 50%;
      color: var(--accent-strong);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .62rem;
      font-weight: 800;
    }

    .playlist-track-copy {
      min-width: 0;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    .playlist-track-copy strong,
    .playlist-track-copy span {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .playlist-track-copy strong {
      font-size: .78rem;
      line-height: 1.12;
    }

    .playlist-track-copy span {
      margin-top: 2px;
      color: var(--muted);
      font-size: .63rem;
    }

    .playlist-track-state {
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .58rem;
      font-weight: 750;
    }

    .playlist-track.active .playlist-track-state { color: var(--accent-strong); }

    .playlist-now {
      flex: 0 0 auto;
      min-width: 0;
      padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
      border-top: 1px solid var(--border);
      background: var(--surface);
      box-shadow: 0 -12px 28px rgba(0, 0, 0, .25);
    }

    .playlist-now-copy > p {
      margin: 0 0 3px;
      color: var(--accent);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .59rem;
      font-weight: 850;
      letter-spacing: .11em;
      text-transform: uppercase;
    }

    .playlist-now-copy h3 {
      margin: 0;
      overflow: hidden;
      font-size: .98rem;
      font-weight: 500;
      line-height: 1.12;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .playlist-now-copy > span {
      display: block;
      margin-top: 3px;
      overflow: hidden;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .68rem;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .playlist-status {
      min-height: 16px;
      margin: 5px 0 0;
      overflow: hidden;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .63rem;
      line-height: 1.25;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .playlist-controls {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-wrap: nowrap;
      gap: clamp(8px, 3.5vw, 17px);
      width: 100%;
      margin-top: 8px;
      overflow: hidden;
    }

    .playlist-control {
      display: grid;
      place-items: center;
      flex: 0 0 42px;
      width: 42px;
      height: 42px;
      min-width: 0;
      min-height: 0;
      padding: 0;
      border: 0;
      border-radius: 50%;
      background: transparent;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      line-height: 1;
      cursor: pointer;
      transition: color .16s ease, transform .16s ease, background-color .16s ease;
    }

    .playlist-control svg {
      width: 23px;
      height: 23px;
      overflow: visible;
      fill: currentColor;
    }

    .playlist-mode svg {
      fill: none;
      stroke: currentColor;
      stroke-linecap: round;
      stroke-linejoin: round;
      stroke-width: 1.8;
    }

    .playlist-control-main {
      display: inline-grid;
      flex: 0 0 54px;
      width: 54px;
      min-width: 54px;
      max-width: 54px;
      height: 54px;
      min-height: 54px;
      max-height: 54px;
      aspect-ratio: 1;
      place-items: center;
      overflow: hidden;
      border-radius: 999px;
      background: var(--text);
      color: var(--bg);
      box-shadow: 0 4px 16px rgba(0, 0, 0, .28);
    }

    .playlist-control-main svg {
      grid-area: 1 / 1;
      display: block;
      width: 25px;
      height: 25px;
      margin: 0;
    }
    .playlist-control-main .playlist-icon-play { transform: translateX(1px); }
    .playlist-control-main .playlist-icon-pause,
    .playlist-control-main.is-playing .playlist-icon-play { display: none; }
    .playlist-control-main.is-playing .playlist-icon-pause { display: block; }

    .playlist-mode {
      position: relative;
      color: var(--muted);
    }

    .playlist-mode span { display: none; }

    #playlist-repeat.repeat-one span {
      position: absolute;
      top: 50%;
      left: 50%;
      display: block;
      font-size: .48rem;
      font-weight: 900;
      line-height: 1;
      transform: translate(-50%, -50%);
    }

    .playlist-mode.active {
      background: transparent;
      color: var(--accent);
      box-shadow: none;
    }

    .playlist-mode.active::after {
      position: absolute;
      bottom: 2px;
      width: 4px;
      height: 4px;
      border-radius: 50%;
      background: currentColor;
      content: "";
    }

    #playlist-repeat { flex-basis: 42px; width: 42px; }

    .playlist-control:disabled {
      cursor: not-allowed;
      opacity: .38;
    }

    @media (hover: hover) {
      .playlist-video-toggle:not(:disabled):hover {
        border-color: rgba(255, 255, 255, .42);
        background: rgba(255, 255, 255, .08);
      }

      .playlist-control:not(:disabled):hover {
        color: var(--text);
        transform: scale(1.08);
      }

      .playlist-mode.active:not(:disabled):hover { color: var(--accent-strong); }
      .playlist-control-main:not(:disabled):hover {
        background: var(--text);
        color: var(--bg);
        transform: scale(1.06);
      }
    }

    .playlist-video-toggle:not(:disabled):active,
    .playlist-control:not(:disabled):active { transform: scale(.96); }

    @media (min-width: 1100px) {
      body { padding-right: 340px; }

      .playlist-menu-trigger,
      .playlist-backdrop,
      .playlist-close { display: none; }

      .playlist {
        width: 340px;
        visibility: visible;
        transform: translateX(0);
        transition: none;
      }

      .playlist-heading {
        padding-top: 12px;
        touch-action: auto;
      }

      .playlist-heading::before { display: none; }

      .catalog-actions .desktop-link-edit { display: inline-flex; }

      .desktop-link-edit.active {
        border-color: var(--accent-strong);
        background: var(--accent-strong);
        color: var(--accent-ink);
      }

      .desktop-list-heading {
        display: grid;
        grid-template-columns: minmax(190px, 1.4fr) minmax(90px, .7fr) 66px 282px;
        gap: 10px;
        padding: 0 10px 7px;
        color: var(--muted);
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        font-size: .68rem;
        font-weight: 800;
        letter-spacing: .08em;
        text-transform: uppercase;
      }

      .desktop-list-heading.link-edit-mode {
        grid-template-columns: minmax(190px, .85fr) minmax(320px, 2fr);
      }

      .pieces {
        grid-template-columns: 1fr;
        gap: 6px;
      }

      .piece {
        display: grid;
        grid-template-columns: minmax(190px, 1.4fr) minmax(90px, .7fr) 66px 282px;
        align-items: center;
        gap: 10px;
        overflow: visible;
        padding: 8px 10px;
        border-radius: 10px;
        box-shadow: none;
      }

      .piece-head {
        grid-column: 1;
        grid-template-columns: 34px minmax(0, 1fr);
        align-items: center;
        gap: 9px;
        min-width: 0;
      }

      .rank {
        width: 34px;
        height: 34px;
        font-size: .72rem;
      }

      .piece-head > div:last-child,
      .title,
      .composer { min-width: 0; }

      .title {
        overflow: hidden;
        font-size: .96rem;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .composer {
        overflow: hidden;
        margin-top: 3px;
        font-size: .7rem;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .genre {
        grid-column: 2;
        display: block;
        overflow: hidden;
        min-width: 0;
        margin: 0;
        padding: 0;
        border: 0;
        background: transparent;
        font-size: .7rem;
        line-height: 1.25;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .genre.empty { display: block; visibility: visible; }

      .piece-details,
      .piece-details-unavailable {
        grid-column: 3;
        display: block;
        min-width: 0;
        margin: 0;
        font-size: .7rem;
      }

      .piece-details summary {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .piece-details[open] {
        grid-column: 1 / -1;
        padding: 8px 43px 4px;
        border-top: 1px solid var(--border);
      }

      .piece-details[open] .piece-metadata {
        grid-template-columns: repeat(5, minmax(0, 1fr));
      }

      .actions {
        grid-column: 4;
        display: flex;
        gap: 6px;
        margin: 0;
      }

      .actions .button {
        flex: 0 0 42px;
        width: 42px;
        min-height: 38px;
        padding: 0;
        border-radius: 9px;
      }

      .actions .button-label { display: none; }

      .pieces.link-edit-mode .piece {
        grid-template-columns: minmax(190px, .85fr) minmax(320px, 2fr);
      }

      .pieces.link-edit-mode .genre,
      .pieces.link-edit-mode .piece-details,
      .pieces.link-edit-mode .piece-details-unavailable,
      .pieces.link-edit-mode .actions { display: none !important; }

      .pieces.link-edit-mode .quick-video-editor {
        grid-column: 2;
        display: grid;
        grid-template-columns: minmax(150px, 1fr) repeat(3, 38px) 70px;
        align-items: center;
        gap: 5px;
        min-width: 0;
      }

      .quick-video-input {
        width: 100%;
        min-width: 0;
        height: 38px;
        padding: 0 10px;
        border: 1px solid var(--border);
        border-radius: 9px;
        background: var(--surface-3);
        color: var(--text);
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        font-size: .78rem;
      }

      .quick-video-button {
        display: grid;
        width: 38px;
        height: 38px;
        place-items: center;
        padding: 0;
        border: 1px solid var(--border);
        border-radius: 9px;
        background: var(--surface-2);
        color: var(--text);
        text-decoration: none;
        cursor: pointer;
      }

      .quick-video-button svg { width: 17px; height: 17px; }
      .quick-save { border-color: transparent; background: var(--accent); color: var(--accent-ink); }
      .quick-remove { color: var(--danger); font-size: 1.25rem; }
      .quick-video-button:disabled { cursor: not-allowed; opacity: .38; }

      .quick-video-status {
        overflow: hidden;
        color: var(--muted);
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        font-size: .62rem;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .quick-video-status.success { color: var(--accent-strong); }
      .quick-video-status.error { color: var(--danger); }
      .quick-video-status.working,
      .quick-video-status.queued { color: var(--accent-strong); }
    }

    @media (min-width: 1540px) {
      .pieces { grid-template-columns: 1fr; }
    }

    .auth-dialog {
      width: min(calc(100% - 28px), 680px);
      max-height: calc(100dvh - 28px);
      overflow-y: auto;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 20px;
      background: var(--surface);
      color: var(--text);
      box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
    }

    .auth-dialog::backdrop {
      background: rgba(0, 0, 0, .72);
      backdrop-filter: blur(7px);
    }

    .auth-form { padding: 20px; }

    .auth-form h2 {
      margin: 0;
      font-size: 1.45rem;
      font-weight: 500;
    }

    .auth-form > p {
      margin: 9px 0 18px;
      color: var(--muted);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .87rem;
      line-height: 1.5;
    }

    .auth-field { margin-top: 12px; }

    .auth-field label {
      display: block;
      margin-bottom: 7px;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .84rem;
      font-weight: 800;
    }

    .auth-field input,
    .auth-field select,
    .metadata-grid input,
    .metadata-grid select {
      width: 100%;
      min-height: var(--tap);
      padding: 10px 12px;
      border: 1px solid var(--border);
      border-radius: 12px;
      background: var(--surface-3);
      color: var(--text);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: 16px;
    }

    .field-clear-button {
      margin-top: 7px;
      padding: 4px 0;
      border: 0;
      background: transparent;
      color: var(--danger);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: .75rem;
      font-weight: 750;
      cursor: pointer;
    }

    .field-clear-button:disabled { opacity: .35; cursor: not-allowed; }

    .metadata-fields {
      margin-top: 18px;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    .metadata-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 12px;
      margin-top: 14px;
    }

    .metadata-grid label {
      display: grid;
      gap: 7px;
      color: var(--text);
      font-size: .8rem;
      font-weight: 750;
    }

    .import-preview {
      display: grid;
      gap: 7px;
      max-height: 300px;
      overflow-y: auto;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    .import-preview-row {
      display: grid;
      grid-template-columns: 34px minmax(0, 1fr);
      gap: 2px 10px;
      padding: 9px 10px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--surface-2);
    }

    .import-preview-row > span {
      grid-row: 1 / 3;
      color: var(--accent-strong);
      font-weight: 800;
    }

    .import-preview-row small,
    .assist-track span,
    .assist-track small {
      color: var(--muted);
    }

    .assist-track {
      display: grid;
      gap: 5px;
      padding: 16px;
      border: 1px solid var(--border);
      border-radius: 14px;
      background: var(--surface-2);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    .assist-track strong { font-size: 1.15rem; }
    .assist-search { width: 100%; margin-top: 14px; }

    .assist-actions {
      display: grid;
      grid-template-columns: 1fr;
      gap: 9px;
      margin-top: 18px;
    }

    .auth-error {
      margin: 10px 0 0 !important;
      color: var(--danger) !important;
    }

    .auth-error[hidden] { display: none; }

    .auth-actions {
      display: grid;
      grid-template-columns: 1fr;
      gap: 9px;
      margin-top: 18px;
    }

    @media (min-width: 460px) {
      .auth-actions { grid-template-columns: 1fr 1fr; }
      .metadata-grid { grid-template-columns: 1fr 1fr; }
      .assist-actions { grid-template-columns: auto auto minmax(0, 1fr); }
    }
