/* Make Your Perfect Session — pill toolbar + modal glass */

.perfect-session-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    padding: 0 12px 0 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 105, 180, 0.42);
    background: rgba(255, 45, 160, 0.12);
    color: #ffb3d9;
    cursor: pointer;
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(255, 105, 180, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.12s;
}
.perfect-session-pill:hover {
    color: #fff;
    background: rgba(255, 45, 160, 0.22);
    border-color: rgba(255, 105, 180, 0.7);
    box-shadow: 0 0 18px rgba(255, 105, 180, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}
.perfect-session-pill:active { transform: translateY(0); }
.perfect-session-pill svg {
    display: block;
    flex-shrink: 0;
    filter: drop-shadow(0 0 4px rgba(255, 105, 180, 0.45));
}
.perfect-session-pill .ps-pill-label {
    line-height: 1;
}

/* Legacy classes */
.perfect-session-fab,
.perfect-session-btn { display: none !important; }

#perfectSessionOverlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top, 0px)) 20px max(12px, env(safe-area-inset-bottom, 0px));
    background: rgba(10, 8, 16, 0.22);
    backdrop-filter: blur(10px) saturate(1.08);
    -webkit-backdrop-filter: blur(10px) saturate(1.08);
}
#perfectSessionOverlay.is-open {
    display: flex;
    height: 100dvh;
    max-height: 100dvh;
    box-sizing: border-box;
}

.ps-modal {
    position: relative;
    width: min(1120px, 100%);
    max-height: min(78vh, 680px);
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(
        155deg,
        rgba(34, 26, 42, 0.72) 0%,
        rgba(22, 16, 30, 0.76) 50%,
        rgba(14, 10, 20, 0.8) 100%
    );
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px) saturate(1.08);
    -webkit-backdrop-filter: blur(14px) saturate(1.08);
    overflow: hidden;
    color: #fff;
    min-height: 0;
}

.ps-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 14px 52px 10px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.ps-title-wrap {
    min-width: 0;
    text-align: center;
}
.ps-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 750;
    letter-spacing: 0.03em;
    color: #ff9ec8;
    text-shadow: 0 0 14px rgba(255, 105, 180, 0.35);
}
.ps-subtitle {
    margin: 4px 0 0;
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.35;
}
.ps-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    pointer-events: auto;
    touch-action: manipulation;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
}
.ps-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.ps-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 22px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overscroll-behavior: contain;
}

.ps-section-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 8px;
}

.ps-tag-search {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
    padding: 9px 14px;
    font-size: 0.82rem;
    outline: none;
}
.ps-tag-search::placeholder {
    color: rgba(255, 255, 255, 0.35);
}
.ps-tag-search:focus {
    border-color: rgba(0, 212, 255, 0.45);
}

.ps-tags {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
    /* 2 lignes de pills (~28px) + 1 gap */
    height: 62px;
    max-height: 62px;
    overflow-x: hidden;
    overflow-y: auto;
    flex-shrink: 0;
}
.ps-tag {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
    color: rgba(255, 255, 255, 0.62);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ps-tag:hover {
    color: #fff;
    border-color: rgba(0, 212, 255, 0.3);
    background: rgba(0, 212, 255, 0.08);
}
.ps-tag.is-on {
    color: #fff;
    border-color: rgba(0, 212, 255, 0.45);
    background: rgba(0, 212, 255, 0.14);
}
.ps-tag.is-hidden {
    display: none;
}
.ps-tags-empty {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
}

.ps-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 18px;
}
@media (max-width: 720px) {
    .ps-controls {
        grid-template-columns: 1fr;
    }
}

.ps-control {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 14px;
}
.ps-control-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.ps-control-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: #00d4ff;
}


.ps-dur-mode {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}
.ps-dur-mode-btn {
    flex: 1;
    appearance: none;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 7px 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ps-dur-mode-btn:hover {
    color: #fff;
    border-color: rgba(255, 105, 180, 0.35);
    background: rgba(255, 105, 180, 0.08);
}
.ps-dur-mode-btn.is-on {
    color: #fff;
    border-color: rgba(255, 105, 180, 0.5);
    background: rgba(255, 105, 180, 0.18);
}

.ps-range {
    width: 100%;
    accent-color: #00d4ff;
    cursor: pointer;
}
.ps-range-marks {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.38);
}

.ps-select-native {
    display: none;
}
.ps-custom-select {
    position: relative;
    width: 100%;
    z-index: 2;
}
.ps-custom-select.open {
    z-index: 8;
}
.ps-custom-trigger {
    width: 100%;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.22);
    color: rgba(255, 255, 255, 0.88);
    padding: 9px 34px 9px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    position: relative;
}
.ps-custom-trigger::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid rgba(255, 255, 255, 0.45);
    border-bottom: 2px solid rgba(255, 255, 255, 0.45);
    transform: translateY(-65%) rotate(45deg);
    transition: transform 0.15s;
}
.ps-custom-select.open .ps-custom-trigger::after {
    transform: translateY(-20%) rotate(225deg);
}
.ps-custom-options {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(18, 14, 28, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
    max-height: 220px;
    overflow-y: auto;
}
.ps-custom-select.open .ps-custom-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.ps-custom-option {
    padding: 8px 12px;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    border-radius: 8px;
}
.ps-custom-option:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.ps-custom-option.selected {
    color: #00d4ff;
    font-weight: 700;
    background: rgba(0, 212, 255, 0.12);
}


.ps-groups-block {
    border: 1px solid rgba(255, 105, 180, 0.18);
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(255, 45, 160, 0.05);
    flex-shrink: 0;
}
.ps-group-kind {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}
.ps-group-kind-btn {
    flex: 1;
    appearance: none;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 7px 8px;
    cursor: pointer;
}
.ps-group-kind-btn:hover {
    color: #fff;
    border-color: rgba(255, 105, 180, 0.35);
    background: rgba(255, 105, 180, 0.08);
}
.ps-group-kind-btn.is-on {
    color: #fff;
    border-color: rgba(255, 105, 180, 0.5);
    background: rgba(255, 105, 180, 0.18);
}
.ps-group-search {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
    padding: 9px 14px;
    font-size: 0.82rem;
    outline: none;
}
.ps-group-search:focus { border-color: rgba(255, 105, 180, 0.45); }
.ps-group-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* ~3.5 rangées (min-height 32 + gap 4) */
    height: 124px;
    max-height: 124px;
    overflow-x: hidden;
    overflow-y: auto;
    flex-shrink: 0;
}
.ps-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 32px;
    box-sizing: border-box;
    text-align: left;
    appearance: none;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.78);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.78rem;
    flex-shrink: 0;
}
.ps-group-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}
.ps-group-item.is-on {
    border-color: rgba(255, 105, 180, 0.45);
    background: rgba(255, 105, 180, 0.16);
    color: #fff;
}
.ps-group-item .ps-group-count {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 700;
    color: #ff9ec8;
}
.ps-group-hint {
    margin: 6px 0 0;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.42);
}
.ps-group-empty {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    padding: 8px 2px;
}

.ps-gen-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.ps-status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}
.ps-status.is-error {
    color: #ff8aa8;
}

.ps-playlist-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
}
.ps-playlist-meta strong {
    color: #00d4ff;
    font-weight: 700;
}

.ps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.ps-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.28);
    aspect-ratio: 16 / 9;
}
.ps-card .ps-thumb-box {
    position: absolute;
    inset: 0;
    overflow: hidden;
    cursor: default;
}
.ps-card img.static-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s;
}
.ps-card video.preview-vid {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    opacity: 0;
    pointer-events: none;
}
.ps-card .ps-badges {
    position: absolute;
    left: 6px;
    bottom: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    z-index: 2;
    pointer-events: none;
}
.ps-card .ps-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    backdrop-filter: blur(6px);
}
.ps-card .ps-badge.bg-human { background: rgba(0, 255, 157, 0.45); }
.ps-card .ps-badge.bg-ai { background: rgba(120, 90, 255, 0.55); }
.ps-card .ps-badge.bg-mp3 { background: rgba(255, 180, 40, 0.5); }
.ps-card .ps-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 3;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ps-card .ps-remove:hover {
    background: rgba(220, 40, 80, 0.65);
}
.ps-card .ps-title-chip {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    padding: 6px 34px 18px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.65), transparent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 2;
    pointer-events: none;
}

.ps-empty {
    padding: 28px 12px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.88rem;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 14px;
}

.ps-footer {
    position: relative;
    z-index: 5;
    pointer-events: auto;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
}
/* Callers: gallery.html + perfect_session_web.js. API: none. Schema: .glass-btn-* / .ps-body scrollbar.
   User: « les boutons ne sont pas dans le thème et la barre de scroll verticale doit etre en rose pour la mettre en évidence. » */
.glass-btn-accent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    padding: 12px 18px;
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid #00d4ff;
    background: transparent;
    color: #00d4ff;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.55), 0 0 18px rgba(0, 212, 255, 0.25);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.28), inset 0 0 12px rgba(0, 212, 255, 0.05);
    transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.glass-btn-accent:hover {
    background: rgba(0, 212, 255, 0.08);
    color: #7fffff;
    border-color: #00d4ff;
    text-shadow: 0 0 12px rgba(0, 212, 255, 0.75), 0 0 22px rgba(0, 212, 255, 0.35);
    box-shadow: 0 0 18px rgba(0, 212, 255, 0.45), 0 0 28px rgba(0, 212, 255, 0.2), inset 0 0 12px rgba(0, 212, 255, 0.08);
    transform: translateY(-1px);
}
.glass-btn-accent:active { transform: translateY(0); }
.glass-btn-accent:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.glass-btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    padding: 12px 18px;
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: transparent;
    color: #ccc;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.glass-btn-ghost:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.04);
}

.ps-footer .glass-btn-accent,
.ps-footer .glass-btn-ghost,
.ps-gen-row .glass-btn-accent,
.ps-gen-row .glass-btn-ghost,
.ps-playlist-meta .glass-btn-ghost {
    min-width: 0;
    padding: 10px 16px;
}

.ps-body {
    scrollbar-width: thin;
    scrollbar-color: #ff2da0 rgba(255, 45, 160, 0.12);
}
.ps-body::-webkit-scrollbar {
    width: 10px;
}
.ps-body::-webkit-scrollbar-track {
    background: rgba(255, 45, 160, 0.08);
    border-radius: 999px;
    margin: 6px 0;
}
.ps-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #ff69b4 0%, #ff1493 55%, #ff2da0 100%);
    border-radius: 999px;
    border: 2px solid rgba(20, 12, 24, 0.35);
    box-shadow: 0 0 10px rgba(255, 45, 160, 0.45);
}
.ps-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #ff9ec8 0%, #ff2da0 100%);
    box-shadow: 0 0 14px rgba(255, 45, 160, 0.65);
}
