/* ======================================================================
   Composants partagés : boutons, pochettes, en-têtes, barre d'actions,
   liste de morceaux, vignettes, états, menus, fenêtres, notifications,
   contrôles de formulaire.
   ====================================================================== */

/* ---------- Boutons ---------- */

/* Les couleurs sur fond sombre / image sont posées par le conteneur parent. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); height: 44px; padding: 0 var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: transparent; color: var(--text); font: inherit; font-weight: 650; white-space: nowrap; text-decoration: none; cursor: pointer; transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s; }
.btn:hover { border-color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn.btn-primary { border-color: transparent; background: var(--accent); color: var(--on-accent); }
.btn.btn-primary:hover { border-color: transparent; background: var(--accent-2); }
.btn.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn.btn-danger:hover { background: var(--danger); color: var(--bg); }
.btn-icon { position: relative; display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer; transition: color 0.15s, background 0.15s, transform 0.1s; }
.btn-icon.sm { width: 36px; height: 36px; }
.btn-icon:hover { color: var(--text); background: var(--hover); }
.btn-icon:active { transform: scale(0.93); }
.btn-icon[aria-pressed="true"] { color: var(--accent); }
.btn:focus-visible, .btn-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn-icon:disabled, .btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.action-icon { width: 46px; height: 46px; }
.save-btn { width: 46px; height: 46px; }
.like-btn.pop .icon, .save-btn.pop .icon { animation: heart-pop 0.35s var(--ease); }
@keyframes heart-pop { 40% { transform: scale(1.3); } }

.follow-btn[aria-pressed="true"] { border-color: var(--text); }
.text-btn { padding: var(--sp-2) 0; border: 0; background: none; color: var(--text-2); font-weight: 700; font-size: var(--fs-caption); }
.text-btn:hover { color: var(--text); }

.play-fab {
  position: relative; z-index: var(--z-raised);
  width: 56px; height: 56px; flex: none;
  display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, background 0.15s, opacity 0.2s;
}
.play-fab:hover { transform: scale(1.05); background: var(--accent-2); }
.play-fab:active { transform: scale(0.97); }
.play-fab .icon { transform: translateX(1px); }
.play-fab[aria-label="Pause"] .icon { transform: none; }
.play-fab .eq { display: none; height: 18px; gap: 3px; }
.play-fab .eq i { width: 4px; background: currentColor; }
.play-fab.active .eq { display: inline-flex; }
.play-fab.active .icon { display: none; }
.play-fab.active:hover .eq, .play-fab.active:focus-visible .eq { display: none; }
.play-fab.active:hover .icon, .play-fab.active:focus-visible .icon { display: block; }
.play-fab.busy .icon { opacity: 0; }
.play-fab.busy::after { content: ""; position: absolute; width: 22px; height: 22px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }


.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-4) 0 var(--sp-2); }
.chip { height: 32px; padding: 0 var(--sp-4); border: 0; border-radius: var(--r-pill); background: var(--hover); color: var(--text); font-size: var(--fs-caption); font-weight: 600; transition: background 0.15s; }
.chip:hover { background: var(--active); }
.chip[aria-selected="true"] { background: var(--text); color: var(--bg-2); }
.chip-kind { padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); background: var(--bg); color: var(--text); font-size: var(--fs-caption); font-weight: 700; }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Pochettes ---------- */

.cover { position: relative; width: var(--size, 48px); height: var(--size, 48px); flex: none; border-radius: var(--radius-s); overflow: hidden; background: var(--surface-3); }
.cover img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.35s ease; }
.cover img.loaded { opacity: 1; }
.cover.round { border-radius: 50%; }
.cover.empty { display: grid; place-items: center; color: var(--text-3); background: linear-gradient(135deg, var(--surface-3), var(--surface-2)); }
.liked-art { display: grid; place-items: center; color: var(--white); background: linear-gradient(135deg, #4a1fd8 0%, #7b6cf6 45%, #9fd3f5 100%); }
.mosaic-cover { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.mosaic-cover img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- En-têtes de page et de section ---------- */

.page-head { padding: calc(88px + var(--safe-top)) var(--gutter) var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); }
@media (max-width: 767px) { .page-head { padding-top: calc(72px + var(--safe-top)); } }  /* sous la barre du haut (64px) */
.page-head h1 { margin: 0; font-size: var(--fs-title); font-weight: 800; letter-spacing: -0.03em; }
.page-head p { max-width: 70ch; }
.section { margin-top: var(--sp-6); margin-bottom: var(--sp-5); }
.section > h2 { font-size: var(--fs-section); font-weight: 800; letter-spacing: -0.02em; margin-bottom: var(--sp-4); }
.section-title { margin: 0 0 var(--sp-3); padding: 0; font-size: var(--fs-section); font-weight: 700; letter-spacing: -0.01em; text-transform: none; color: var(--text-1); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.section-head h2 { margin: 0; }
.section-head .play-fab { width: 48px; height: 48px; }
.shelf { margin-top: var(--sp-6); }
.shelf-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.shelf-head h2 { font-size: var(--fs-section); font-weight: 800; letter-spacing: -0.02em; margin-bottom: var(--sp-2); }
.shelf-tools { display: flex; align-items: center; gap: var(--sp-1); }
.shelf-more { margin-right: var(--sp-2); font-size: var(--fs-caption); font-weight: 700; color: var(--text-2); }
.shelf-more:hover { color: var(--text); text-decoration: underline; }

/* ---------- Barre d'actions ---------- */

.action-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-4); padding: var(--sp-5) 0 var(--sp-5); }
.list-tools { display: flex; align-items: center; gap: var(--sp-3); margin-left: auto; }
.list-filter, .list-sort { display: inline-flex; align-items: center; gap: var(--sp-2); height: 36px; padding: 0 var(--sp-3); border-radius: var(--r-pill); background: var(--hover); color: var(--text-2); transition: background 0.15s; }
.list-filter:focus-within, .list-sort:focus-within { background: var(--active); color: var(--text); }
.list-filter input { width: 190px; border: 0; background: none; color: var(--text); font-size: var(--fs-caption); }
.list-filter input::placeholder { color: var(--text-3); }
.list-sort select { border: 0; background: none; color: var(--text); font-size: var(--fs-caption); font-weight: 600; cursor: pointer; }
.list-sort option { background: var(--menu-bg); color: var(--text); }
.copyright { margin-top: var(--sp-5); font-size: var(--fs-caption); color: var(--text-3); }

/* ---------- Liste de morceaux ---------- */

.tracklist { --cols: 40px minmax(0, 1fr) 40px 56px 40px; }
.tracklist.with-album { --cols: 40px minmax(0, 5fr) minmax(0, 3fr) 40px 56px 40px; }
.tl-head, .tl-row { display: grid; grid-template-columns: var(--cols); align-items: center; column-gap: var(--sp-4); padding: 0 var(--sp-3); }
.tl-head { height: 36px; margin-bottom: var(--sp-2); border-bottom: 1px solid var(--line); color: var(--text-3); font-size: var(--fs-caption); }
.tl-head .tl-dur { display: flex; justify-content: flex-end; padding-right: 2px; }
.tl-row { min-height: 56px; border-radius: var(--radius-s); transition: background 0.12s; }
.tl-row:hover { background: var(--hover); }
.tl-row:focus { background: var(--active); outline: none; }
.tl-row:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--line-strong); }
.tl-num { position: relative; display: grid; place-items: center; height: 100%; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: var(--fs-body); }
.tl-play { display: none; width: 32px; height: 32px; padding: 0; border: 0; background: none; color: var(--text); place-items: center; }
.tl-row:hover .tl-index, .tl-row:focus .tl-index { display: none; }
.tl-row:hover .tl-play, .tl-row:focus .tl-play { display: grid; }
.tl-main { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.tl-text { min-width: 0; }
.tl-title { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: var(--fs-body); font-weight: 550; }
.tl-title span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-sub { display: flex; align-items: center; font-size: var(--fs-caption); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-sub a:hover, .tl-album a:hover, .pb-artists a:hover, .q-sub a:hover, .info-artists a:hover { text-decoration: underline; color: var(--text); }
.tl-album { font-size: var(--fs-caption); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-dur { text-align: right; font-size: var(--fs-caption); color: var(--text-2); font-variant-numeric: tabular-nums; }
.tl-like .btn-icon, .tl-more .btn-icon { opacity: 0; width: 32px; height: 32px; }
.tl-row:hover .btn-icon, .tl-row:focus-within .btn-icon, .tl-like .btn-icon[aria-pressed="true"] { opacity: 1; }
.tl-row.is-current .tl-title, .tl-row.is-current .tl-index { color: var(--accent); }
.tl-dl { display: none; flex: none; margin-right: var(--sp-2); color: var(--accent); --dl-arrow: var(--bg); vertical-align: -2px; }
.tl-row[data-dl="done"] .tl-dl { display: inline-flex; }
body.is-offline .tl-row:not([data-dl="done"]) { opacity: 0.4; }
.explicit { display: inline-grid; place-items: center; width: 16px; height: 16px; flex: none; border-radius: 3px; background: var(--text-3); color: var(--bg-2); font-size: 10px; font-weight: 800; }

.eq { display: none; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { display: block; width: 3px; height: 100%; border-radius: 1px; background: var(--accent); transform-origin: bottom; animation: eq 0.9s ease-in-out infinite; animation-play-state: paused; }
.eq i:nth-child(2) { animation-delay: -0.35s; }
.eq i:nth-child(3) { animation-delay: -0.7s; }
body.is-playing .eq i { animation-play-state: running; }
@keyframes eq { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
.tl-row.is-playing .eq { display: inline-flex; }
.tl-row.is-playing .tl-index { display: none; }
.tl-row.is-playing:hover .eq, .tl-row.is-playing:focus .eq { display: none; }
.eq.on { display: inline-flex; }

/* ---------- Vignettes, rangées et listes ---------- */

.row-arrow { background: var(--hover); }
.row-scroll { display: grid; grid-auto-flow: column; grid-auto-columns: clamp(148px, 15vw, 196px); gap: var(--sp-1); margin: 0 calc(var(--sp-3) * -1); padding: 0 0 var(--sp-2); overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scroll-padding: 0 12px; scrollbar-width: none; }
.row-scroll::-webkit-scrollbar { display: none; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--sp-1); margin: 0 calc(var(--sp-3) * -1); }

.card { position: relative; padding: var(--sp-4); border-radius: var(--r-lg); scroll-snap-align: start; transition: background 0.2s; min-width: 0; }
.card:hover, .card:focus-within { background: var(--hover); }
.card-art { position: relative; margin-bottom: var(--sp-3); }
.card .cover { width: 100%; height: auto; aspect-ratio: 1; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); border-radius: var(--r-sm); }
.card.round .cover { border-radius: 50%; }
.card .mosaic-cover { width: 100%; height: auto; aspect-ratio: 1; }
.card .liked-art { width: 100%; height: auto; aspect-ratio: 1; display: grid; place-items: center; }
.card-art .play-fab { position: absolute; z-index: calc(var(--z-raised) + 1); /* au-dessus du lien étiré de la carte */ right: 8px; bottom: 8px; width: 48px; height: 48px; opacity: 0; transform: translateY(8px); }
.card:hover .play-fab, .card:focus-within .play-fab, .card-art .play-fab[aria-label="Pause"] { opacity: 1; transform: none; }
.card-link { display: block; font-weight: 700; font-size: var(--fs-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-link::after { content: ""; position: absolute; inset: 0; z-index: var(--z-raised); border-radius: var(--radius); }
.card-sub { margin-top: var(--sp-1); font-size: var(--fs-caption); color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 1.45em; }
.card.round .card-link, .card.round .card-sub { text-align: center; }

.list { background: var(--surface); border-radius: var(--radius-l); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; width: 100%; padding: var(--sp-3) var(--sp-4); box-sizing: border-box; text-align: left; color: inherit; font: inherit; text-decoration: none; background: transparent; border: 0; border-radius: 0; cursor: pointer; }
.row:hover { background: var(--hover); }
.row:active { background: var(--active); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; color: var(--text-2); }
.row-main { flex: 1; min-width: 0; }
.row-title, .row-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title { font-size: 1em; }
.row-sub { font-size: 0.85em; color: var(--text-2); }
.row:has(.row-end .btn) .row-title { white-space: normal; overflow-wrap: anywhere; }
.row-end .btn { white-space: nowrap; }
.row-end { display: inline-flex; align-items: center; flex: none; gap: var(--sp-2); color: var(--text-2); }
.row-avatar { display: inline-flex; flex: none; }
.list > .row.row { width: 100%; }
.chevron { display: inline-block; width: 8px; height: 8px; flex: none; border-top: 2px solid var(--text-3); border-right: 2px solid var(--text-3); transform: rotate(45deg); }

/* ---------- États ---------- */

.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: 64px var(--sp-4); text-align: center; }
.empty-state h2 { font-size: var(--fs-section); font-weight: 750; }
.empty-state p { max-width: 46ch; color: var(--text-2); }
.empty-icon { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: var(--sp-2); border-radius: 50%; background: var(--surface-2); color: var(--text-2); }
.empty-state.compact { gap: var(--sp-2); padding: var(--sp-7) var(--sp-3); }
.empty-state.compact h2 { font-size: inherit; font-weight: 400; }
.empty-state.compact .empty-icon { width: auto; height: auto; margin-bottom: var(--sp-1); background: none; color: var(--text-3); }

.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: var(--r-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-line { height: 12px; width: 70%; margin: var(--sp-2) 0; }
.sk-line.short { width: 40%; }
.sk-title { height: 48px; width: 60%; margin: var(--sp-3) 0; border-radius: var(--r-sm); }
.sk-art { width: clamp(150px, 20vw, 232px); aspect-ratio: 1; border-radius: var(--r-sm); }
.sk-cover { width: 40px; height: 40px; flex: none; }
.sk-card { width: 100%; aspect-ratio: 1; border-radius: var(--r-sm); margin-bottom: var(--sp-3); }
.skeleton-hero { background: none; }
.skeleton-list { padding: var(--sp-5) var(--gutter); display: flex; flex-direction: column; gap: var(--sp-2); }
.sk-row { display: flex; align-items: center; gap: var(--sp-4); height: 56px; }
.sk-lines { flex: 1; }

/* ---------- Menus, panneaux, fenêtres, notifications ---------- */

.menu { position: fixed; z-index: var(--z-overlay); min-width: 230px; max-width: 320px; padding: var(--sp-1); border-radius: var(--r-md); background: var(--menu-bg); box-shadow: 0 18px 50px var(--scrim), 0 0 0 1px var(--line); opacity: 0; transform: scale(0.97); transform-origin: top right; transition: opacity 0.12s, transform 0.12s; }
.menu.open { opacity: 1; transform: none; }
.menu-item { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: var(--sp-3) var(--sp-3); border: 0; border-radius: var(--r-sm); background: none; color: var(--text); text-align: left; font-size: var(--fs-caption); }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item:disabled { opacity: 0.4; pointer-events: none; }
.menu-item.danger { color: var(--danger); }
.menu-item .icon { color: var(--text-2); }
.menu-item.danger .icon { color: var(--danger); }
.menu-item[aria-checked="true"] { color: var(--accent); }
.menu-item[aria-checked="true"] .icon:last-child { color: var(--accent); }
.menu-icon-space { width: 18px; flex: none; }
.menu-label { flex: 1; min-width: 0; }
.menu-hint { color: var(--text-3); font-size: var(--fs-caption); }
.menu-sep { height: 1px; margin: var(--sp-1) var(--sp-2); background: var(--line); }
.menu-backdrop { position: fixed; inset: 0; z-index: var(--z-overlay); }
.menu-backdrop.visible { background: var(--scrim); animation: fade-in 0.15s; }
.menu.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; max-width: none; min-width: 0; padding: var(--sp-2) var(--sp-2) calc(var(--sp-3) + var(--safe-bottom)); border-radius: var(--r-lg) var(--r-lg) 0 0; transform: translateY(100%); transition: transform 0.28s var(--ease); max-height: calc(100vh - 16px - var(--safe-top)); max-height: calc(100dvh - 16px - var(--safe-top)); overflow-y: auto; overscroll-behavior: contain; }
.menu.sheet.open { transform: none; }
.menu.sheet .menu-item { padding: var(--sp-4) var(--sp-3); font-size: var(--fs-body); }
@keyframes fade-in { from { opacity: 0; } }
.sheet-handle { width: 36px; height: 4px; margin: var(--sp-2) auto var(--sp-3); border-radius: 2px; background: var(--line-strong); touch-action: none; }
.menu-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-1) var(--sp-3) var(--sp-4); margin-bottom: var(--sp-1); border-bottom: 1px solid var(--line); }
.menu-head-img { width: 48px; height: 48px; border-radius: 4px; object-fit: cover; }
.menu-head-text { min-width: 0; display: flex; flex-direction: column; }
.menu-head-text strong { font-size: var(--fs-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-head-text span { color: var(--text-2); font-size: var(--fs-caption); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.modal-backdrop { position: fixed; inset: 0; z-index: var(--z-overlay); background: var(--scrim-strong); opacity: 0; transition: opacity 0.15s; }
.modal-backdrop.open { opacity: 1; }
.modal { position: fixed; z-index: var(--z-modal); left: 50%; top: 50%; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); display: flex; flex-direction: column; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); transform: translate(-50%, -48%); opacity: 0; transition: opacity 0.15s, transform 0.15s; }
.modal.open { opacity: 1; transform: translate(-50%, -50%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-4) var(--sp-2) var(--sp-5); }
.modal-head h2 { font-size: var(--fs-section); font-weight: 800; }
.modal-body { padding: var(--sp-1) var(--sp-5) var(--sp-5); overflow-y: auto; }
.modal.modal-small { width: min(440px, calc(100vw - 32px)); }
.modal-form { display: flex; flex-direction: column; gap: var(--sp-3); }
.modal-text { color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-3); margin-top: var(--sp-2); }
.shortcuts { display: grid; grid-template-columns: 1fr; gap: 2px; margin: 0; }
.shortcut { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.shortcut dt { color: var(--text-2); font-size: var(--fs-caption); white-space: nowrap; }
.shortcut dd { margin: 0; text-align: right; font-size: var(--fs-caption); }
kbd { display: inline-block; min-width: 24px; padding: 2px var(--sp-2); border-radius: var(--r-sm); background: var(--surface-3); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); color: var(--text); font: 600 12px/1.6 var(--font); text-align: center; }

.toasts { position: fixed; z-index: var(--z-toast); left: 50%; bottom: calc(var(--player-h) + var(--sp-5)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: var(--sp-4); max-width: 520px; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--toast-bg); color: var(--toast-ink); font-size: var(--fs-caption); font-weight: 550; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); pointer-events: auto; animation: toast-in 0.2s ease; }
.toast.error { background: var(--toast-error-bg); color: var(--toast-error-ink); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.toast-action { padding: 0; border: 0; background: none; color: inherit; font-weight: 800; text-decoration: underline; white-space: nowrap; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Contrôles de formulaire ---------- */

.input, .select { box-sizing: border-box; width: 100%; height: 44px; padding: 0 var(--sp-4); border: 1px solid transparent; border-radius: var(--r-pill); background-color: var(--surface-3); color: var(--text); font: inherit; -webkit-appearance: none; appearance: none; }
textarea.input { height: auto; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); resize: vertical; }
.input.lg { height: 60px; font-size: var(--fs-title); }
.input::placeholder { color: var(--text-3); }
.input:focus-visible, .select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.list-filter input:focus-visible, .search-box .input:focus-visible { outline: none; }
.search-box .input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; border-radius: 0; background: none; }
.search-box .input::-webkit-search-cancel-button { display: none; }
.input:disabled, .select:disabled { opacity: 0.45; cursor: not-allowed; }
.select {
  padding-right: var(--sp-7);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23b4bbc6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.range { --fill: var(--accent); -webkit-appearance: none; appearance: none; width: 100%; height: 24px; margin: 0; padding: 0; background: transparent; color: var(--accent); cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: var(--r-pill); background: linear-gradient(to right, var(--fill) var(--p, 0%), var(--buffer) var(--p, 0%), var(--buffer) var(--b, var(--p, 0%)), var(--track, var(--surface-3)) var(--b, var(--p, 0%))); }
.range::-moz-range-track { height: 4px; border-radius: var(--r-pill); background: linear-gradient(to right, var(--buffer) var(--b, var(--p, 0%)), var(--track, var(--surface-3)) var(--b, var(--p, 0%))); }
.range::-moz-range-progress { height: 4px; border-radius: var(--r-pill); background: var(--fill); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border: 0; border-radius: 50%; background: var(--knob); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.12s; }
.range::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--knob); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.12s; }
.range:focus-visible { --fill: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-pill); }
.range:focus-visible::-webkit-slider-thumb { opacity: 1; }
.range:focus-visible::-moz-range-thumb { opacity: 1; }
.range-v { --fill: 50%; writing-mode: vertical-lr; direction: rtl; width: 24px; height: 140px; margin: 0; padding: 0; background: transparent; cursor: pointer; -webkit-appearance: none; appearance: none; }
.range-v::-webkit-slider-runnable-track { width: 6px; border-radius: var(--r-pill); background: linear-gradient(to top, var(--accent) var(--fill), var(--surface-3) var(--fill)); }
.range-v::-moz-range-track { width: 6px; border-radius: var(--r-pill); background: linear-gradient(to top, var(--accent) var(--fill), var(--surface-3) var(--fill)); }
.range-v::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-left: -6px; border: 2px solid var(--accent); border-radius: 50%; background: var(--knob); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); opacity: 1; }
.range-v::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid var(--accent); border-radius: 50%; background: var(--knob); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); opacity: 1; }
.range-v:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-pill); }

.switch { position: relative; display: inline-flex; flex: none; width: 44px; height: 26px; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--surface-3); transition: background 0.2s; pointer-events: none; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); transition: transform 0.2s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--text); outline-offset: 2px; }
.switch-track { position: relative; width: 44px; height: 26px; border-radius: var(--r-pill); background: var(--line); box-shadow: inset 0 0 0 1.5px var(--line-strong); transition: background 0.2s var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--knob); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); transition: transform 0.2s var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); box-shadow: none; }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.45; }

/* ---------- Animations d'apparition et gestes ---------- */

.card, .tl-row { animation: rise 0.35s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); }
.no-enter { animation: none !important; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.tl-row, .card { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* ---------- Écrans tactiles, téléphone, mouvement réduit ---------- */

@media (hover: none) {
  .tl-like .btn-icon, .tl-more .btn-icon { opacity: 1; }
  .card-art .play-fab { opacity: 1; transform: none; }
  .range::-webkit-slider-thumb { opacity: 1; }
  .range::-moz-range-thumb { opacity: 1; }
  .tl-sub a, .tl-album a, .q-sub a { pointer-events: none; }
  .tl-row:active { background: var(--hover); }
}

@media (max-width: 767px) {
  .toasts { bottom: calc(var(--player-h) + 72px + var(--safe-bottom)); }
  .action-bar { gap: var(--sp-2); padding: var(--sp-4) 0 var(--sp-3); }
  .action-bar .play-fab { order: 9; margin-left: auto; }
  .list-tools { order: 10; flex: 1 1 100%; margin: var(--sp-2) 0 0; }
  .list-filter { flex: 1; min-width: 0; }
  .list-filter input { width: 100%; }
  .list-sort select { font-size: var(--fs-body); }
  .tracklist, .tracklist.with-album { --cols: minmax(0, 1fr) 36px; }
  .tl-head, .tl-num, .tl-album, .tl-dur, .tl-like { display: none !important; }
  .tl-row { padding: 0 var(--sp-1) 0 0; min-height: 60px; }
  .tl-more .btn-icon { opacity: 1; }
  .tl-row:hover { background: transparent; }
  .tl-row.is-playing .tl-title::after { content: ""; }
  .row-scroll { grid-auto-columns: 40vw; }
  .row-arrow { display: none; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-art .play-fab { display: none; }
  .shortcuts .shortcut dt { white-space: normal; }
  .modal.modal-small { top: auto; bottom: calc(12px + var(--safe-bottom)); transform: translate(-50%, 8px); }
  .modal.modal-small.open { transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .switch-track, .switch-track::after { transition: none; }
}

/* ---------- Réordonnancement par glisser (dragsort.js) ---------- */
.drag-handle { display: inline-grid; place-items: center; width: 32px; height: 44px; color: var(--text-3); cursor: grab; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.drag-handle:hover { color: var(--text); }
.tl-row.dragging, .dragging { position: relative; z-index: var(--z-raised); background: var(--active); box-shadow: var(--shadow); cursor: grabbing; opacity: 0.96; }
body.is-sorting { user-select: none; -webkit-user-select: none; cursor: grabbing; }
@media (prefers-reduced-motion: reduce) { .drag-handle, .dragging { transition: none; } }

/* Recadrage de photo */
.cropper { display: flex; flex-direction: column; gap: var(--sp-3); align-items: center; }
.cropper-stage { position: relative; width: min(320px, 80vw); aspect-ratio: 1; overflow: hidden; background: #000; touch-action: none; cursor: grab; user-select: none; border-radius: var(--r-md, 8px); }
.cropper-stage:active { cursor: grabbing; }
.cropper-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cropper-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; pointer-events: none; will-change: transform; }
.cropper-stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8); }
.cropper-stage.is-circle::after { background: radial-gradient(circle closest-side, transparent calc(100% - 1px), rgba(0, 0, 0, 0.65) 100%); box-shadow: none; }
.cropper .range { width: min(320px, 80vw); }
.cropper .modal-actions { align-self: stretch; }
@media (prefers-reduced-motion: reduce) { .cropper-img { transition: none; } }

/* Champ du pseudo (Réglages et écran d'accueil) */
.username-field { display: flex; flex-direction: column; gap: var(--sp-2); text-align: left; }
.username-group { display: flex; align-items: center; gap: var(--sp-2); height: 48px; padding: 0 var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-3); color: var(--text); }
.username-group:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.username-at, .username-count { color: var(--text-2); font-variant-numeric: tabular-nums; }
.username-count { font-size: var(--fs-caption); }
.username-input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-size: var(--fs-body); text-align: left; text-transform: none; letter-spacing: normal; outline: none; }
.username-help { margin: 0; color: var(--text-2); font-size: var(--fs-caption); }
.username-status { min-height: 1.4em; margin: 0; font-size: var(--fs-caption); font-weight: 600; color: var(--danger); }
.username-status.ok { color: var(--accent); }
.username-form.in-modal { display: flex; flex-direction: column; gap: var(--sp-4); }
.username-actions { display: flex; justify-content: flex-end; gap: var(--sp-3); }
.username-actions .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pair-actions .btn:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 767px) {
  .chip { min-height: 40px; }
}
