/* ═══════════════════════════════════════════════════════
   MusicPreparator — Design System
   Theme: Dark mode, party vibes (violet/rose/blue gradients)
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── CSS Variables ─── */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16162a;
    --bg-input: #1e1e3a;
    --bg-hover: #252545;

    --text-primary: #f0f0ff;
    --text-secondary: #a0a0c0;
    --text-muted: #6b6b8d;

    --accent-violet: #a78bfa;
    --accent-pink: #f472b6;
    --accent-blue: #60a5fa;
    --accent-green: #4ade80;
    --accent-orange: #fb923c;

    --gradient-primary: linear-gradient(135deg, #a78bfa 0%, #f472b6 100%);
    --gradient-header: linear-gradient(135deg, #1a1a3e 0%, #2a1a3e 50%, #1a2a3e 100%);

    --border-color: rgba(167, 139, 250, 0.15);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(167,139,250,0.2);

    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-violet);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--accent-pink); }

/* ─── Layout ─── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ─── Header ─── */
.header {
    background: var(--gradient-header);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
}

.header__logo-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px rgba(167,139,250,0.5));
}

.header__logo-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn--primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(167,139,250,0.3);
}
.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(167,139,250,0.4);
}
.btn--primary:active {
    transform: translateY(0);
}

.btn--secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn--secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent-violet);
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
}
.btn--ghost:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}

.btn--danger {
    background: rgba(239,68,68,0.15);
    color: #f87171;
    border: 1px solid rgba(239,68,68,0.3);
}
.btn--danger:hover {
    background: rgba(239,68,68,0.25);
}

.btn--sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-icon:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* ─── Input ─── */
.input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    outline: none;
}
.input:focus {
    border-color: var(--accent-violet);
    box-shadow: 0 0 0 3px rgba(167,139,250,0.15);
}
.input::placeholder {
    color: var(--text-muted);
}

/* ─── Import Bar ─── */
.import-bar {
    display: flex;
    gap: 10px;
    padding: 20px 0;
}

.import-bar .input {
    flex: 1;
    font-size: 1rem;
    padding: 14px 18px;
}

.import-bar .btn {
    padding: 14px 24px;
    font-size: 1rem;
}

.import-bar--loading .btn {
    pointer-events: none;
    opacity: 0.7;
}

/* ─── Event Info ─── */
.event-info {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.event-info__left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.event-info__name {
    font-size: 1.4rem;
    font-weight: 700;
}

.event-info__date {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.event-info__visibility {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.event-info__edit-code {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--accent-violet);
}

/* ─── Toggle Switch ─── */
.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle__slider {
    width: 44px;
    height: 24px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    position: relative;
    transition: all var(--transition-base);
}

.toggle__slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-base);
}

.toggle__input:checked + .toggle__slider {
    background: rgba(167,139,250,0.3);
    border-color: var(--accent-violet);
}

.toggle__input:checked + .toggle__slider::before {
    transform: translateX(20px);
    background: var(--accent-violet);
}

.toggle__label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ─── Category Tabs ─── */
.category-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.category-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xl);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.category-tab:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.category-tab--active {
    background: var(--accent-violet);
    color: white;
    border-color: var(--accent-violet);
    box-shadow: 0 2px 10px rgba(167,139,250,0.3);
}

.category-tab--all {
    border-style: dashed;
}

.category-tab--add {
    border-style: dashed;
    border-color: var(--text-muted);
    color: var(--text-muted);
}
.category-tab--add:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

/* ─── Category Badge (inline) ─── */
.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border: 1px solid;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ─── Track Cards Grid ─── */
.tracks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.track-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: all var(--transition-base);
    animation: cardAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.track-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(167,139,250,0.1);
    border-color: var(--cat-color, var(--accent-violet));
}

.track-card[draggable="true"] {
    cursor: grab;
}
.track-card[draggable="true"]:active {
    cursor: grabbing;
}

.track-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg) scale(0.98);
}

.track-card.drag-over {
    border-color: var(--accent-violet);
    box-shadow: 0 0 0 2px var(--accent-violet), var(--shadow-glow);
}

.track-card--removing {
    animation: cardRemove 0.3s ease-out forwards;
}

@keyframes cardAppear {
    0% { opacity: 0; transform: scale(0.9) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes cardRemove {
    0% { opacity: 1; transform: scale(1) translateX(0); }
    100% { opacity: 0; transform: scale(0.9) translateX(30px); }
}

.track-card__thumb {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--bg-primary);
}

.track-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.track-card:hover .track-card__thumb img {
    transform: scale(1.05);
}

.track-card__play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    color: white;
    font-size: 2rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
    text-decoration: none;
}
.track-card:hover .track-card__play {
    opacity: 1;
}

.track-card__info {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.track-card__title {
    font-weight: 600;
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.track-card__artist {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.track-card__actions {
    display: flex;
    gap: 4px;
    padding: 0 10px 10px;
    justify-content: flex-end;
}

/* ─── Playlist Cards ─── */
.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.playlist-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition-base);
    animation: cardAppear 0.4s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.playlist-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--accent-violet);
    color: var(--text-primary);
}

.playlist-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.playlist-card__visibility {
    font-size: 1.2rem;
}

.playlist-card__owned-badge {
    background: var(--gradient-primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 10px;
}

.playlist-card__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.playlist-card__name {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.playlist-card__date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.playlist-card__count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ─── Sections ─── */
.section {
    padding: 24px 0;
}

.section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.section__title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.section__divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

/* ─── Access Code Section ─── */
.access-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    margin: 20px 0;
}

.access-section__title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.access-section__form {
    display: flex;
    gap: 10px;
}

.access-section__form .input {
    flex: 1;
    font-family: monospace;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* ─── Toast ─── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    transform: translateX(100px);
    opacity: 0;
    transition: all var(--transition-base);
    pointer-events: auto;
    min-width: 280px;
    font-size: 0.9rem;
}

.toast--visible {
    transform: translateX(0);
    opacity: 1;
}

.toast--success { border-left: 3px solid var(--accent-green); }
.toast--error   { border-left: 3px solid #ef4444; }
.toast--info    { border-left: 3px solid var(--accent-blue); }
.toast--warning { border-left: 3px solid var(--accent-orange); }

.toast__icon { font-size: 1.1rem; flex-shrink: 0; }
.toast__msg  { flex: 1; }

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    opacity: 0;
    transition: opacity var(--transition-base);
    padding: 20px;
}

.modal-overlay--visible {
    opacity: 1;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 28px;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform var(--transition-base);
}

.modal-overlay--visible .modal {
    transform: scale(1);
}

.modal__title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal__content {
    margin-bottom: 20px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal__content .input {
    margin-top: 8px;
}

.modal__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ─── Loading ─── */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 20px;
    color: var(--text-muted);
}

.loading__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-violet);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Empty State ─── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 60px 20px;
    text-align: center;
}

.empty-state__icon {
    font-size: 3rem;
    opacity: 0.4;
}

.empty-state__msg {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 350px;
}

/* ─── Hero (Homepage) ─── */
.hero {
    text-align: center;
    padding: 48px 20px 24px;
}

.hero__title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 12px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero__subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 500px;
    margin: 0 auto;
}

/* ─── Create Form (in modal) ─── */
.create-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.create-form__group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.create-form__label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Category Selector (in modal for changing track category) ─── */
.category-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-selector__option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    width: 100%;
    text-align: left;
}

.category-selector__option:hover {
    background: var(--bg-hover);
    border-color: var(--accent-violet);
}

/* ─── Back Link ─── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}
.back-link:hover {
    color: var(--accent-violet);
}

/* ─── Online Player Bar ─── */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 8000;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
}

.player-bar--visible {
    transform: translateY(0);
}

/* Hidden YouTube iframe container */
.player-bar__yt-frame {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    top: 0;
    left: 0;
}

.player-bar__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
}

/* Left: track info */
.player-bar__track {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.player-bar__thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.player-bar__meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-bar__title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.player-bar__artist {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Center: controls */
.player-bar__controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.player-bar__buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.player-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.player-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.player-btn--play {
    width: 44px;
    height: 44px;
    background: var(--gradient-primary) !important;
    color: white !important;
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(167,139,250,0.4);
}

.player-btn--play:hover {
    transform: scale(1.08);
    box-shadow: 0 0 24px rgba(167,139,250,0.6);
}

/* Progress bar */
.player-bar__progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 360px;
}

.player-bar__time {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    min-width: 32px;
}

.player-bar__time--right {
    text-align: right;
}

.player-progress {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(
        to right,
        var(--accent-violet) 0%,
        var(--accent-violet) var(--pct, 0%),
        var(--bg-hover) var(--pct, 0%),
        var(--bg-hover) 100%
    );
    cursor: pointer;
    transition: height var(--transition-fast);
    --pct: 0%;
}

.player-progress:hover {
    height: 6px;
}

.player-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 0 6px rgba(0,0,0,0.4);
    cursor: pointer;
}

.player-progress::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    border: none;
    cursor: pointer;
}

/* Right: close + extra */
.player-bar__right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.player-btn--close {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Track card active (currently playing) */
.track-card--playing {
    border-color: var(--accent-violet) !important;
    box-shadow: 0 0 0 2px rgba(167,139,250,0.3), var(--shadow-md) !important;
}

.track-card--playing .track-card__play {
    opacity: 1;
    background: rgba(167,139,250,0.5);
}

/* Make the track-grid leave room for player bar */
.tracks-grid--with-player {
    padding-bottom: 100px;
}

/* Track card play button — in-page mode (not link) */
.track-card__play--btn {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    color: white;
    font-size: 2rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
    border: none;
    cursor: pointer;
    width: 100%;
}

.track-card:hover .track-card__play--btn {
    opacity: 1;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .header__inner {
        flex-wrap: wrap;
    }

    .hero__title {
        font-size: 1.6rem;
    }

    .import-bar {
        flex-direction: column;
    }

    .event-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .tracks-grid {
        grid-template-columns: 1fr;
    }

    .playlist-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .modal {
        max-width: 100%;
    }

    .toast-container {
        left: 10px;
        right: 10px;
    }

    .toast {
        min-width: auto;
    }

    /* Player bar mobile */
    .player-bar__inner {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        padding: 10px 12px;
        gap: 8px;
    }

    .player-bar__track {
        grid-column: 1;
        grid-row: 1;
    }

    .player-bar__controls {
        grid-column: 2;
        grid-row: 1;
    }

    .player-bar__right {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-end;
    }

    .player-bar__progress-row {
        width: 200px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    .playlist-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .playlist-card {
        padding: 14px;
    }

    /* Player bar: stack to compact 2-row layout */
    .player-bar__inner {
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        gap: 6px;
        padding: 8px 10px;
    }

    .player-bar__track {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .player-bar__controls {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .player-bar__right {
        display: none;
    }

    .player-bar__progress-row {
        width: 100%;
    }
}


/* ═══════════════════════════════════════════════════════
   Assistant IA (tri par genres + suggestions)
   Motion : chaque état de l'IA a un retour visuel (étapes, minuteur,
   résultats en direct, confirmation, mise en évidence des changements)
   ═══════════════════════════════════════════════════════ */

.ai-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 12px 0 4px;
    padding: 10px 14px;
    background: linear-gradient(110deg, rgba(167,139,250,0.10), rgba(244,114,182,0.10), rgba(96,165,250,0.08), rgba(167,139,250,0.10));
    background-size: 300% 100%;
    animation: aiSheen 12s linear infinite;
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
}

.ai-bar__label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--accent-violet);
    margin-right: 4px;
}

.ai-modal { max-width: 520px; transition: max-width var(--transition-slow), transform var(--transition-base); }
.ai-modal--wide { max-width: 760px; }

.ai-modal__content {
    max-height: 66vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Transition d'entrée de chaque écran de la modale */
.ai-view { animation: aiViewIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

.ai-hint, .ai-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.ai-meta { margin: 10px 0 0; color: var(--text-muted); }
.ai-hint strong { color: var(--text-primary); }

.ai-choice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.ai-choice:hover { transform: translateY(-1px); }
.ai-choice:hover, .ai-choice:has(input:checked) { border-color: var(--accent-violet); }
.ai-choice:has(input:checked) { box-shadow: 0 0 0 3px rgba(167,139,250,0.15); }
.ai-choice input { margin-top: 4px; accent-color: var(--accent-violet); }
.ai-choice strong { display: block; font-size: 0.92rem; }
.ai-choice small { display: block; margin-top: 2px; font-size: 0.78rem; color: var(--text-muted); }

.ai-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.ai-check input { accent-color: var(--accent-violet); }

select.input { cursor: pointer; }

/* ─── Écran « en cours » ─── */

.ai-run {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: 4px 0 2px;
}

/* Équalizer : l'IA « écoute » vos musiques */
.ai-eq { display: flex; align-items: flex-end; gap: 5px; height: 38px; }
.ai-eq i {
    width: 6px;
    height: 100%;
    border-radius: 3px;
    background: var(--gradient-primary);
    transform-origin: bottom;
    animation: aiEq 1s ease-in-out infinite;
}
.ai-eq i:nth-child(2) { animation-duration: 0.8s; animation-delay: -0.2s; }
.ai-eq i:nth-child(3) { animation-duration: 1.2s; animation-delay: -0.5s; }
.ai-eq i:nth-child(4) { animation-duration: 0.9s; animation-delay: -0.7s; }
.ai-eq i:nth-child(5) { animation-duration: 1.1s; animation-delay: -0.1s; }
.ai-eq--done i { animation: none; transform: scaleY(0.3); opacity: 0.4; transition: all 0.4s; }

.ai-run__title { font-weight: 700; font-size: 1.05rem; }
.ai-run__timer { font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ai-run__note { font-size: 0.78rem; color: var(--text-muted); max-width: 420px; }

.ai-track { width: 100%; height: 6px; background: var(--bg-input); border-radius: 999px; overflow: hidden; }
.ai-track__fill {
    height: 100%;
    width: 0;
    min-width: 6%;
    border-radius: 999px;
    background: linear-gradient(90deg, #a78bfa, #f472b6, #a78bfa);
    background-size: 200% 100%;
    animation: aiShimmer 1.4s linear infinite;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Étapes */
.ai-steps { list-style: none; width: 100%; text-align: left; margin-top: 6px; }
.ai-step { display: flex; gap: 12px; position: relative; padding-bottom: 14px; }
.ai-step:last-child { padding-bottom: 0; }
.ai-step::before {
    content: '';
    position: absolute;
    left: 13px; top: 30px; bottom: 2px;
    width: 2px;
    background: var(--border-color);
    transform-origin: top;
}
.ai-step:last-child::before { display: none; }
.ai-step--done::before { background: var(--accent-violet); animation: aiGrow 0.4s ease-out; }

.ai-step__dot {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.ai-step__dot b { grid-area: 1 / 1; }
.ai-tick {
    grid-area: 1 / 1;
    width: 16px; height: 16px;
    fill: none;
    stroke: #fff;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 24;
    stroke-dashoffset: 24;
}
.ai-step__text strong { display: block; font-size: 0.9rem; transition: opacity 0.3s; }
.ai-step__text small { display: block; font-size: 0.78rem; color: var(--text-muted); min-height: 1em; }
.ai-step--todo .ai-step__text { opacity: 0.5; }

.ai-step--active .ai-step__dot {
    border-color: var(--accent-violet);
    color: var(--text-primary);
    animation: aiPulse 1.6s ease-out infinite;
}
.ai-step--active .ai-step__dot::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--accent-pink);
    animation: aiSpin 0.9s linear infinite;
}
.ai-step--active .ai-step__text small { color: var(--text-secondary); }

.ai-step--done .ai-step__dot { background: var(--gradient-primary); border-color: transparent; }
.ai-step--done .ai-step__dot b { display: none; }
.ai-step--done .ai-tick { animation: aiDraw 0.4s 0.05s ease-out forwards; }

.ai-step--error .ai-step__dot { background: #ef4444; border-color: transparent; color: #fff; animation: aiShake 0.45s; }
.ai-step--error .ai-step__dot b { color: #fff; }
.ai-step--error .ai-step__text small { color: #fca5a5; }

/* Résultats en direct (idées recherchées sur YouTube, genres repérés) */
.ai-live { position: relative; width: 100%; max-height: 220px; overflow-y: auto; text-align: left; margin-top: 4px; }
.ai-live:empty { display: none; }
.ai-live__label {
    margin-bottom: 8px;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    animation: aiViewIn 0.3s both;
}
.ai-live__label[hidden] { display: none; }

.ai-idea {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    margin-bottom: 4px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: 8px;
    animation: aiRowIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: calc(var(--i, 0) * 40ms);
    transition: background 0.3s, border-color 0.3s, opacity 0.3s;
}
.ai-idea__icon {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 18px; height: 18px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
    color: #0f0f1a;
}
.ai-idea__text { min-width: 0; }
.ai-idea__text b, .ai-idea__text small, .ai-idea__text em {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-idea__text b { font-size: 0.85rem; }
.ai-idea__text small { font-size: 0.72rem; color: var(--text-muted); }
.ai-idea__text em { font-style: normal; font-size: 0.75rem; color: var(--text-secondary); }

.ai-idea--wait .ai-idea__icon { border: 2px dashed var(--text-muted); opacity: 0.5; }
.ai-idea--busy { border-color: var(--accent-violet); background: rgba(167,139,250,0.10); }
.ai-idea--busy .ai-idea__icon {
    border: 2px solid rgba(167,139,250,0.3);
    border-top-color: var(--accent-pink);
    animation: aiSpin 0.8s linear infinite;
}
.ai-idea--ok .ai-idea__icon,
.ai-idea--warn .ai-idea__icon,
.ai-idea--fail .ai-idea__icon,
.ai-idea--skip .ai-idea__icon { animation: aiPop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.ai-idea--ok .ai-idea__icon { background: var(--accent-green); }
.ai-idea--ok .ai-idea__icon::after { content: '✓'; }
.ai-idea--warn .ai-idea__icon { background: var(--accent-orange); }
.ai-idea--warn .ai-idea__icon::after { content: '!'; }
.ai-idea--fail .ai-idea__icon { background: #f87171; }
.ai-idea--fail .ai-idea__icon::after { content: '×'; }
.ai-idea--fail { opacity: 0.75; }
.ai-idea--skip .ai-idea__icon { background: var(--text-muted); }
.ai-idea--skip .ai-idea__icon::after { content: '–'; }
.ai-idea--skip { opacity: 0.5; }

/* ─── Pastilles de catégories ─── */

.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ai-run .ai-chips { margin-bottom: 0; }
.ai-success .ai-chips { justify-content: center; margin: 6px 0 0; }
.ai-chip {
    animation: aiPop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1) both;
    transition: opacity 0.25s, transform 0.25s;
}
.ai-chip--out { opacity: 0; transform: scale(0.7); }
.ai-chip__n { display: inline-block; font-variant-numeric: tabular-nums; }
.ai-bump { animation: aiBump 0.35s ease-out; }

/* ─── Bandeau d'explication ─── */

.ai-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, rgba(167,139,250,0.14), rgba(244,114,182,0.10));
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
}
.ai-banner__icon { font-size: 1.4rem; animation: aiPop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.ai-banner strong { display: block; font-size: 0.92rem; }
.ai-banner span:not(.ai-banner__icon) { font-size: 0.8rem; color: var(--text-secondary); }

/* ─── Listes (aperçu du tri, suggestions) ─── */

.ai-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 42vh;
    overflow-y: auto;
    padding-right: 4px;
}

.ai-row {
    display: grid;
    grid-template-columns: 48px 1fr minmax(120px, 170px);
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    transition: opacity 0.25s, border-color 0.25s;
}
.ai-row--in {
    animation: aiRowIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: calc(var(--i, 0) * 45ms);
}
.ai-row--edited { animation: aiEdited 0.7s ease-out; }
.ai-row--off { opacity: 0.55; }
.ai-row--suggestion { grid-template-columns: 20px 64px 1fr minmax(120px, 170px); align-items: start; }
.ai-row--suggestion .ai-row__select { align-self: center; }

.ai-row__check { accent-color: var(--accent-violet); width: 18px; height: 18px; margin-top: 4px; cursor: pointer; }

.ai-row__thumb {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg-input);
}
.ai-row--suggestion .ai-row__thumb { width: 64px; height: 48px; }

.ai-row__info { min-width: 0; }
.ai-row__title {
    font-size: 0.88rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-row--suggestion .ai-row__title { white-space: normal; }
.ai-row__sub { font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-row__reason { font-size: 0.78rem; color: var(--text-secondary); font-style: italic; margin-top: 2px; }
.ai-row__link { display: inline-block; margin-top: 4px; font-size: 0.75rem; color: var(--accent-blue); text-decoration: none; }
.ai-row__link:hover { text-decoration: underline; }
.ai-row__select { padding: 6px 8px; font-size: 0.8rem; }

.ai-warn {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--accent-orange);
    background: rgba(251,146,60,0.12);
    border-radius: 999px;
    white-space: nowrap;
}

/* ─── Confirmation ─── */

.ai-success { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding-top: 6px; }
.ai-success__svg { width: 76px; height: 76px; }
.ai-success__svg circle {
    fill: none;
    stroke: var(--accent-green);
    stroke-width: 3;
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
    transform-origin: center;
    transform: rotate(-90deg);
    animation: aiDrawCircle 0.6s ease-out forwards;
}
.ai-success__svg path {
    fill: none;
    stroke: var(--accent-green);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: aiDrawCheck 0.4s 0.5s ease-out forwards;
}
.ai-success h4 { font-size: 1.15rem; animation: aiViewIn 0.4s 0.45s both; }
.ai-success p { font-size: 0.9rem; color: var(--text-secondary); animation: aiViewIn 0.4s 0.55s both; }
.ai-countdown { width: 100%; max-width: 240px; height: 3px; margin-top: 10px; background: var(--bg-input); border-radius: 999px; overflow: hidden; }
.ai-countdown i { display: block; height: 100%; background: var(--gradient-primary); transform-origin: left; animation: aiCountdown linear forwards; }

/* ─── Erreur ─── */

.ai-fail {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: rgba(248,113,113,0.10);
    border: 1px solid rgba(248,113,113,0.35);
    border-radius: var(--border-radius-sm);
}
.ai-fail__icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-weight: 800;
    animation: aiShake 0.5s;
}
.ai-fail strong { font-size: 0.95rem; }
.ai-fail p { margin-top: 4px; font-size: 0.88rem; color: #fca5a5; }
.ai-fail .ai-fail__hint { color: var(--text-secondary); }

.ai-code {
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    overflow-x: auto;
}

/* ─── Mise en évidence dans la playlist après une action de l'IA ─── */

.track-card--flash {
    position: relative;
    z-index: 1;
    animation: aiFlash 1.5s ease-out 2;
    animation-delay: var(--flash-delay, 0s);
}
.category-tab--flash { animation: aiTabFlash 1.2s ease-out 2; }

/* ─── Keyframes ─── */

@keyframes aiViewIn  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes aiRowIn   { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes aiPop     { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }
@keyframes aiBump    { 0% { transform: scale(1); } 40% { transform: scale(1.5); color: #fff; } 100% { transform: scale(1); } }
@keyframes aiEq      { 0%, 100% { transform: scaleY(0.25); } 50% { transform: scaleY(1); } }
@keyframes aiShimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }
@keyframes aiSheen   { from { background-position: 0 0; } to { background-position: 300% 0; } }
@keyframes aiSpin    { to { transform: rotate(360deg); } }
@keyframes aiPulse   { 0% { box-shadow: 0 0 0 0 rgba(167,139,250,0.55); } 70%, 100% { box-shadow: 0 0 0 10px rgba(167,139,250,0); } }
@keyframes aiGrow    { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes aiDraw    { to { stroke-dashoffset: 0; } }
@keyframes aiDrawCircle { to { stroke-dashoffset: 0; } }
@keyframes aiDrawCheck  { to { stroke-dashoffset: 0; } }
@keyframes aiShake   { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes aiCountdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes aiEdited  { 0% { border-color: var(--accent-pink); box-shadow: 0 0 0 3px rgba(244,114,182,0.35); } 100% { border-color: var(--border-color); box-shadow: 0 0 0 0 rgba(244,114,182,0); } }
@keyframes aiFlash {
    0%   { box-shadow: 0 0 0 0 rgba(167,139,250,0); transform: scale(1); }
    25%  { box-shadow: 0 0 0 3px rgba(167,139,250,0.9), 0 0 32px rgba(244,114,182,0.5); transform: scale(1.025); }
    100% { box-shadow: 0 0 0 0 rgba(167,139,250,0); transform: scale(1); }
}
@keyframes aiTabFlash {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(167,139,250,0); }
    40%      { transform: scale(1.12); box-shadow: 0 0 0 3px rgba(167,139,250,0.6), 0 0 18px rgba(244,114,182,0.5); }
}

@media (max-width: 600px) {
    .ai-row { grid-template-columns: 40px 1fr; }
    .ai-row__select { grid-column: 1 / -1; }
    .ai-row--suggestion { grid-template-columns: 20px 56px 1fr; }
    .ai-row--suggestion .ai-row__select { grid-column: 1 / -1; }
    .ai-banner { align-items: flex-start; }
}

/* Respect des préférences d'accessibilité : pas de mouvement, mais les états restent lisibles */
@media (prefers-reduced-motion: reduce) {
    .ai-view, .ai-row--in, .ai-row--edited, .ai-idea, .ai-chip, .ai-bump, .ai-banner__icon, .ai-live__label,
    .ai-success h4, .ai-success p, .ai-fail__icon, .ai-step--done::before, .ai-step--error .ai-step__dot,
    .ai-idea__icon, .ai-success__svg circle, .ai-success__svg path, .ai-tick {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
    }
    .ai-bar, .ai-eq i, .ai-track__fill, .ai-step__dot, .ai-step__dot::after, .ai-countdown i,
    .track-card--flash, .category-tab--flash {
        animation: none !important;
    }
    .ai-step--active .ai-step__dot { box-shadow: 0 0 0 3px rgba(167,139,250,0.4); }
    .track-card--flash { box-shadow: 0 0 0 3px rgba(167,139,250,0.9); }
}
