/* ===========================================================================
   Profile sheet
   ---------------------------------------------------------------------------
   Loaded after refresh.css and uses its tokens. The markup is in index.html
   (#profile-modal) and the content is drawn by js/profile.js. main.css still
   positions the modal (centred on desktop, a bottom sheet on phones); this
   file restyles what is inside it.
   =========================================================================== */

/* ── Shell ───────────────────────────────────────────────────────────────── */

#profile-modal .profile-modal-content {
    box-sizing: border-box;
    width: calc(100% - 32px);
    max-width: 560px;
    height: min(88vh, 860px);
    max-height: none;
    margin: 6vh auto 0;
    padding: 0 !important;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--bg-color) !important;
    box-shadow: 0 40px 100px rgba(8, 10, 32, 0.45);
    text-align: left;
}

#profile-modal .profile-scroll-area {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 28px;
    scroll-behavior: smooth;
}

#profile-modal .pf-close {
    top: 14px;
    right: 14px;
    z-index: 30;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s var(--ease-out);
}

#profile-modal .pf-close:hover,
#profile-modal .pf-close:focus-visible {
    background: rgba(255, 255, 255, 0.24);
    transform: rotate(90deg);
    box-shadow: none;
}

#profile-modal .pf-close:active {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: scale(0.94);
    box-shadow: none !important;
}

#profile-modal .pf-close .i {
    width: 20px;
    height: 20px;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */

.pf-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: 40px 24px 54px;
    color: #fff;
    text-align: center;
    background:
        radial-gradient(120% 90% at 85% -10%, rgba(109, 74, 255, 0.6) 0%, transparent 55%),
        radial-gradient(90% 80% at 0% 100%, rgba(37, 99, 235, 0.45) 0%, transparent 60%),
        linear-gradient(165deg, #0B1026 0%, #151B52 55%, #231C66 100%);
}

.pf-sky {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.pf-moon {
    position: absolute;
    top: 22px;
    left: 24px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #FFF8DC 0%, #FFE08A 45%, #FFC247 100%);
    box-shadow: 0 0 28px 6px rgba(255, 214, 107, 0.35);
    opacity: 0.9;
}

.pf-avatar-wrap {
    position: relative;
    width: 104px;
    height: 104px;
    margin: 0 auto 14px;
}

.pf-avatar {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #2B2F72, #1A1F52);
    box-shadow:
        0 0 0 4px rgba(255, 255, 255, 0.12),
        0 0 0 7px rgba(255, 194, 71, 0.9),
        0 18px 36px rgba(0, 0, 0, 0.35);
    color: #fff;
    font-family: inherit;
    font-size: 3.3rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.25s var(--ease-spring);
}

.pf-avatar.is-letter {
    background: linear-gradient(135deg, #FFB199 0%, #FF6FA5 100%);
    font-size: 2.8rem;
    font-weight: 900;
}

.pf-avatar:hover {
    transform: scale(1.04) rotate(-4deg);
}

.pf-avatar:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 8px;
}

.pf-avatar-edit {
    position: absolute;
    right: -2px;
    bottom: 2px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFE08A, #FFB547);
    color: #1B1F3B;
    box-shadow: 0 0 0 3px #1A1F52;
    pointer-events: none;
}

.pf-avatar-edit .i {
    width: 15px;
    height: 15px;
}

#profile-modal .pf-name {
    margin: 0 0 8px !important;
    color: #fff;
    font-size: 1.7rem !important;
    font-weight: 900;
    letter-spacing: -0.01em;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

#profile-modal .pf-plan-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 20px !important;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(236, 240, 255, 0.92);
    font-size: 0.82rem !important;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
}

#profile-modal .pf-plan-chip.is-premium {
    background: linear-gradient(135deg, #FFE08A, #FFB547);
    border-color: transparent;
    color: #1B1F3B;
}

#profile-modal .pf-plan-chip.is-premium::before {
    content: '👑';
    font-size: 0.95em;
}

.pf-level {
    max-width: 360px;
    margin: 0 auto;
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    text-align: left;
}

.pf-level-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 10px;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.pf-level-top strong {
    color: #fff;
    font-weight: 800;
}

#pf-level-next {
    color: rgba(236, 240, 255, 0.8);
    font-weight: 700;
}

.pf-level-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}

.pf-level-track.is-light {
    background: var(--surface-2);
}

.pf-level-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #FFE08A, #FFB547);
    box-shadow: 0 0 10px rgba(255, 194, 71, 0.55);
    transition: width 0.8s var(--ease-out);
}

/* ── Avatar picker ───────────────────────────────────────────────────────── */

#profile-modal .avatar-selector {
    margin: 16px 16px 0;
    padding: 16px;
    max-height: none;
    overflow: visible;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
    backdrop-filter: none;
    animation: chipIn 0.2s var(--ease-out);
}

/* An older ui.js opened it with display:flex; the groups need block. */
#profile-modal .avatar-selector[style*="flex"] {
    display: block !important;
}

.avatar-group-label {
    margin: 4px 2px 8px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.avatar-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

#profile-modal .avatar-btn {
    width: 100%;
    height: 48px;
    padding: 0;
    border: 1.5px solid transparent;
    border-radius: 14px;
    background: var(--surface-2);
    font-family: inherit;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s var(--ease-spring), border-color 0.15s, background 0.15s;
}

#profile-modal .avatar-btn:hover {
    transform: scale(1.1);
    background: var(--card-bg);
    border-color: var(--primary-color);
    box-shadow: none;
}

#profile-modal .avatar-btn[aria-pressed="true"] {
    border-color: var(--gold-2);
    background: var(--gold-soft);
}

/* ── Stats ───────────────────────────────────────────────────────────────── */

.pf-stats {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin: -30px 16px 14px;
    padding: 12px 8px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
}

#profile-modal .avatar-selector + .pf-stats {
    margin-top: 14px;
}

.pf-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
    padding: 4px 2px;
    text-align: center;
}

.pf-stat + .pf-stat {
    border-left: 1px solid var(--border);
}

.pf-stat-ico {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 4px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-text);
}

.pf-stat-ico .i {
    width: 18px;
    height: 18px;
}

.pf-stat-ico.is-flame {
    background: rgba(249, 115, 22, 0.12);
    color: var(--streak-color);
}

.pf-stat-ico.is-flame .i {
    fill: rgba(249, 115, 22, 0.25);
}

.pf-stat-ico.is-gold {
    background: var(--gold-soft);
    color: var(--gold-text);
}

.pf-stat strong {
    color: var(--text-main);
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.pf-stat > span:last-child {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.25;
}

/* ── This week ───────────────────────────────────────────────────────────── */

.pf-week {
    margin: 0 16px 14px;
    padding: 14px 16px 16px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--card-bg);
}

.pf-week-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}

.pf-week-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 900;
}

#pf-week-summary {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.pf-week-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pf-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.pf-day-dot {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    color: #fff;
}

.pf-day-dot .i {
    width: 16px;
    height: 16px;
    stroke-width: 3;
}

.pf-day.is-done .pf-day-dot {
    border-color: transparent;
    background: var(--primary-gradient);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.pf-day.is-today .pf-day-dot {
    border-color: var(--gold-2);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

.pf-day.is-today.is-done .pf-day-dot {
    box-shadow: 0 0 0 3px var(--gold-soft), 0 4px 12px rgba(79, 70, 229, 0.35);
}

.pf-day.is-future .pf-day-dot {
    border-style: dashed;
    opacity: 0.6;
}

.pf-day-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.pf-day.is-today .pf-day-label {
    color: var(--text-main);
    font-weight: 900;
}

.pf-week-nudge {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.5;
}

/* ── Plan card ───────────────────────────────────────────────────────────── */

#pf-plan-card:empty {
    display: none;
}

.pf-plan {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 16px 14px;
    padding: 14px 16px;
    border-radius: 22px;
    text-decoration: none;
}

.pf-plan.is-free {
    background:
        radial-gradient(120% 120% at 100% 0%, rgba(255, 194, 71, 0.3), transparent 55%),
        var(--primary-gradient);
    color: #fff;
    box-shadow: var(--shadow-primary);
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
}

.pf-plan.is-free:hover {
    transform: translateY(-2px);
}

.pf-plan.is-premium {
    background: var(--gold-soft);
    border: 1px solid rgba(255, 181, 71, 0.45);
    color: var(--text-main);
}

.pf-plan-ico {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, #FFE08A, #FFB547);
    color: #1B1F3B;
}

.pf-plan-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.pf-plan-text strong {
    font-size: 1rem;
    font-weight: 900;
}

.pf-plan-text span {
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0.9;
}

.pf-plan.is-premium .pf-plan-text span {
    color: var(--text-muted);
    opacity: 1;
}

.pf-plan-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-main);
    font-weight: 800;
    font-size: 0.88rem;
    text-decoration: none;
    border: 1px solid var(--border);
}

.pf-plan .pf-chevron {
    width: 20px;
    height: 20px;
    opacity: 0.85;
}

/* ── Quick actions ───────────────────────────────────────────────────────── */

.pf-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 16px 18px;
}

.pf-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 84px;
    padding: 10px 6px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s var(--ease-out), border-color 0.2s, box-shadow 0.2s;
}

.pf-action:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.pf-action:active {
    transform: scale(0.96);
}

.pf-action-ico {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--primary-text);
    font-size: 1.25rem;
}

.pf-action-ico .i {
    width: 20px;
    height: 20px;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */

.pf-tabs {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin: 0 0 6px;
    padding: 8px 16px;
    background: var(--bg-color);
    background: color-mix(in srgb, var(--bg-color) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.pf-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 6px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.pf-tab:hover {
    color: var(--text-main);
}

.pf-tab[aria-selected="true"] {
    background: var(--card-bg);
    color: var(--text-main);
    box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border);
}

.pf-tab[aria-selected="true"]::after {
    content: '';
    position: absolute;
    left: 30%;
    right: 30%;
    bottom: 4px;
    height: 3px;
    border-radius: 3px;
    background: var(--primary-gradient);
}

.pf-tab-count {
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--gold-soft);
    color: var(--gold-text);
    font-size: 0.72rem;
    font-weight: 900;
}

.pf-tab-count:empty {
    display: none;
}

.pf-panel {
    padding: 4px 16px 0;
    animation: fadeIn 0.2s ease;
}

.pf-panel[hidden] {
    display: none;
}

/* ── Library ─────────────────────────────────────────────────────────────── */

.pf-section {
    margin-bottom: 22px;
}

.pf-section[hidden] {
    display: none;
}

.pf-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.pf-section-head h3 {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--text-main);
    font-size: 1.02rem;
    font-weight: 900;
}

.pf-section-head h3 .i {
    width: 18px;
    height: 18px;
    color: var(--primary-text);
}

.pf-count {
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.pf-count:empty {
    display: none;
}

.pf-rail {
    display: flex;
    gap: 12px;
    margin: 0 -16px;
    padding: 2px 16px 6px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scroll-padding-left: 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.pf-rail::-webkit-scrollbar {
    display: none;
}

.pf-card {
    flex: 0 0 136px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-main);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    scroll-snap-align: start;
}

.pf-card-art {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 31 / 24;
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface-2);
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s var(--ease-out), box-shadow 0.25s;
}

.pf-card-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pf-card:hover .pf-card-art {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.pf-card:active .pf-card-art {
    transform: scale(0.97);
}

.pf-card:focus-visible {
    outline: none;
}

.pf-card:focus-visible .pf-card-art {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.pf-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.84rem;
    font-weight: 800;
    line-height: 1.35;
}

.pf-card-tag {
    position: absolute;
    top: 6px;
    left: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(8, 10, 32, 0.68);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pf-card-tag .i {
    width: 12px;
    height: 12px;
}

.pf-card.is-local .pf-card-art img {
    filter: saturate(0.6);
}

.pf-card-progress {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.45);
    overflow: hidden;
}

.pf-card-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #FFE08A, #FFB547);
}

.pf-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1.5px dashed var(--border-strong);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.55;
}

.pf-text-btn {
    min-height: 36px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary-text);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.pf-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--primary-text);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
}

.pf-link-btn .i {
    width: 16px;
    height: 16px;
}

.pf-link-btn:hover {
    border-color: var(--primary-color);
}

/* Loading placeholders */
.pf-skeleton-rail {
    display: flex;
    gap: 12px;
}

.pf-skeleton-rail span,
.pf-skeleton-list span {
    display: block;
    border-radius: 16px;
    background: linear-gradient(90deg, var(--skeleton-base) 8%, var(--skeleton-shine) 18%, var(--skeleton-base) 33%);
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite linear;
}

.pf-skeleton-rail span {
    flex: 0 0 136px;
    height: 105px;
}

.pf-skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pf-skeleton-list span {
    height: 60px;
}

/* Playlists */
.pf-playlists {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pf-playlist {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 6px 6px 8px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--card-bg);
}

.pf-playlist-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    min-height: 52px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-main);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.pf-playlist-art {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--primary-soft);
}

.pf-playlist-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pf-playlist-art:empty::before {
    content: '♪';
    color: var(--primary-text);
    font-size: 1.3rem;
    font-weight: 900;
}

.pf-playlist-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.pf-playlist-text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.95rem;
    font-weight: 800;
}

.pf-playlist-text span {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.pf-playlist-play {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
}

.pf-playlist-play .i {
    width: 16px;
    height: 16px;
    margin-left: 2px;
}

.pf-icon-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.pf-icon-btn:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #DC2626;
}

.pf-icon-btn .i {
    width: 19px;
    height: 19px;
}

/* Listening history */
.pf-hist-list {
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--card-bg);
}

.pf-hist-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 64px;
    padding: 8px 12px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    color: var(--text-main);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.pf-hist-row:last-child {
    border-bottom: 0;
}

.pf-hist-row:hover {
    background: var(--surface-2);
}

.pf-hist-row img {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 12px;
    object-fit: cover;
    background: var(--surface-2);
}

.pf-hist-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.pf-hist-text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: 800;
}

.pf-hist-text span {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.pf-hist-state {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
}

.pf-hist-state.is-done {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
}

html[data-theme="dark"] .pf-hist-state.is-done {
    color: #6EE7B7;
}

.pf-hist-state .i {
    width: 13px;
    height: 13px;
    stroke-width: 3;
}

.pf-more {
    margin-top: 6px;
}

/* ── Medals ──────────────────────────────────────────────────────────────── */

.pf-medal-summary {
    margin-bottom: 14px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--card-bg);
}

.pf-medal-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 10px;
}

.pf-medal-head strong {
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
    color: var(--gold-text);
}

.pf-medal-head span {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.9rem;
}

.pf-next-medal {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 16px;
    background: var(--surface-2);
}

.pf-next-ico {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 14px;
    background: var(--card-bg);
    font-size: 1.6rem;
    filter: grayscale(0.4);
}

.pf-next-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.pf-next-text strong {
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 900;
}

.pf-medals {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 0 !important;
}

#profile-modal .medal-card {
    padding: 14px 8px 12px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    box-shadow: none;
    gap: 2px;
}

#profile-modal .medal-card .medal-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 8px;
    border-radius: 50%;
    font-size: 1.8rem;
}

#profile-modal .medal-card.unlocked {
    border-color: rgba(255, 181, 71, 0.55);
    background: linear-gradient(180deg, var(--gold-soft), var(--card-bg) 70%);
}

#profile-modal .medal-card.unlocked .medal-icon {
    background: linear-gradient(135deg, #FFE08A, #FFB547);
    box-shadow: 0 6px 16px rgba(255, 181, 71, 0.4);
}

#profile-modal .medal-card.locked {
    opacity: 1;
    filter: none;
    border-style: dashed;
}

#profile-modal .medal-card.locked .medal-icon {
    background: var(--surface-2);
    filter: grayscale(1);
    opacity: 0.45;
}

#profile-modal .medal-card.locked .medal-title {
    color: var(--text-muted);
}

#profile-modal .medal-title {
    font-size: 0.8rem;
    font-weight: 900;
    line-height: 1.3;
}

#profile-modal .medal-desc {
    font-size: 0.7rem;
    line-height: 1.35;
}

/* ── Settings ────────────────────────────────────────────────────────────── */

.pf-group {
    margin-bottom: 20px;
}

.pf-group-title {
    margin: 0 4px 8px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.pf-group > .pf-row,
.pf-group > .pf-details {
    border: 1px solid var(--border);
    border-top-width: 0;
    background: var(--card-bg);
}

.pf-group > :is(.pf-row, .pf-details):nth-child(2) {
    border-top-width: 1px;
    border-radius: 18px 18px 0 0;
}

.pf-group > :is(.pf-row, .pf-details):last-child {
    border-radius: 0 0 18px 18px;
}

.pf-group > :is(.pf-row, .pf-details):nth-child(2):last-child {
    border-radius: 18px;
}

.pf-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 8px 14px;
    box-sizing: border-box;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    list-style: none;
    transition: background 0.15s;
}

.pf-row::-webkit-details-marker {
    display: none;
}

.pf-row:hover {
    background: var(--surface-2);
}

.pf-details > .pf-row {
    border: 0;
    background: none;
    border-radius: inherit;
}

.pf-row-ico {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 11px;
    background: var(--primary-soft);
    color: var(--primary-text);
}

.pf-row-ico .i {
    width: 19px;
    height: 19px;
}

.pf-row-ico.is-gold {
    background: var(--gold-soft);
    color: var(--gold-text);
}

.pf-row-ico.is-fb {
    background: rgba(24, 119, 242, 0.12);
    color: #1877F2;
}

.pf-row-label {
    flex: 1;
    min-width: 0;
}

.pf-row-value {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.pf-row-value.is-on,
#push-notif-row.is-on .pf-row-value {
    background: rgba(16, 185, 129, 0.13);
    color: #047857;
}

html[data-theme="dark"] .pf-row-value.is-on,
html[data-theme="dark"] #push-notif-row.is-on .pf-row-value {
    color: #6EE7B7;
}

.pf-chevron {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.2s var(--ease-out);
}

.pf-details[open] > summary .pf-chevron {
    transform: rotate(90deg);
}

.pf-details-body {
    padding: 4px 14px 16px 62px;
    animation: fadeIn 0.2s ease;
}

.pf-help {
    margin: 0 0 10px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.5;
}

.pf-error {
    margin: 0 0 10px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(220, 38, 38, 0.1);
    color: #B91C1C;
    font-size: 0.85rem;
    font-weight: 700;
}

html[data-theme="dark"] .pf-error {
    color: #FCA5A5;
}

.pf-inline {
    display: flex;
    gap: 8px;
}

.pf-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 48px;
    box-sizing: border-box;
    padding: 0 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 14px;
    background: var(--bg-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pf-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--ring);
}

.pf-field-label {
    display: block;
    margin: 0 0 6px;
    color: var(--text-main);
    font-size: 0.82rem;
    font-weight: 800;
}

.pf-pass {
    position: relative;
    margin-bottom: 12px;
}

.pf-pass .pf-input {
    padding-right: 48px;
}

.pf-eye {
    position: absolute;
    right: 2px;
    top: 2px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}

.pf-eye[aria-pressed="true"] {
    color: var(--primary-text);
}

.pf-eye .i {
    width: 19px;
    height: 19px;
}

.pf-btn {
    flex-shrink: 0;
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 14px;
    background: var(--primary-gradient);
    color: #fff;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow-primary);
    transition: transform 0.15s, filter 0.2s;
}

.pf-btn:hover {
    filter: brightness(1.06);
}

.pf-btn:active {
    transform: scale(0.97);
}

.pf-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.pf-btn-block {
    width: 100%;
}

#pf-reminder-off {
    margin-top: 8px;
    color: #B91C1C;
}

html[data-theme="dark"] #pf-reminder-off {
    color: #FCA5A5;
}

/* The switch */
.pf-switch {
    position: relative;
    width: 52px;
    height: 32px;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--border-strong);
    cursor: pointer;
    transition: background 0.2s;
}

.pf-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: transform 0.22s var(--ease-spring);
}

.pf-switch[aria-checked="true"] {
    background: var(--primary-gradient);
}

.pf-switch[aria-checked="true"]::after {
    transform: translateX(20px);
}

.pf-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    margin: 6px 0 8px;
    border: 1.5px solid rgba(220, 38, 38, 0.35);
    border-radius: 16px;
    background: rgba(220, 38, 38, 0.06);
    color: #B91C1C;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.pf-logout:hover {
    background: #DC2626;
    border-color: #DC2626;
    color: #fff;
}

html[data-theme="dark"] .pf-logout {
    color: #FCA5A5;
}

html[data-theme="dark"] .pf-logout:hover {
    color: #fff;
}

.pf-logout .i {
    width: 19px;
    height: 19px;
}

/* ── Dark ────────────────────────────────────────────────────────────────── */

html[data-theme="dark"] #profile-modal .profile-modal-content {
    border-color: rgba(163, 171, 255, 0.14);
}

html[data-theme="dark"] .pf-tabs {
    background: color-mix(in srgb, var(--bg-color) 86%, transparent);
}

/* ── Phones: main.css turns the modal into a bottom sheet ────────────────── */

@media (max-width: 600px) {
    #profile-modal .profile-modal-content {
        width: 100%;
        max-width: 100%;
        height: 94%;
        margin: 0;
        border-radius: 28px 28px 0 0;
        border-bottom: 0;
    }

    #profile-modal .profile-modal-content::before {
        background: #fff;
        opacity: 0.45;
    }

    #profile-modal .profile-scroll-area {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }

    .pf-hero {
        padding: 44px 16px 50px;
    }

    .pf-avatar-wrap {
        width: 92px;
        height: 92px;
    }

    .pf-avatar {
        font-size: 2.9rem;
    }

    #profile-modal .pf-name {
        font-size: 1.5rem !important;
    }

    .pf-stats,
    .pf-week,
    .pf-plan,
    .pf-actions {
        margin-left: 12px;
        margin-right: 12px;
    }

    #profile-modal .avatar-selector {
        margin: 14px 12px 0;
    }

    .pf-stat strong {
        font-size: 1.1rem;
    }

    .pf-stat > span:last-child {
        font-size: 0.66rem;
    }

    .pf-stat-ico {
        width: 30px;
        height: 30px;
    }

    .pf-day-dot {
        width: 30px;
        height: 30px;
    }

    .pf-tabs {
        padding: 8px 12px;
        gap: 2px;
    }

    .pf-tab {
        gap: 4px;
        padding: 0 2px;
        font-size: 0.8rem;
    }

    .pf-tab-count {
        padding: 1px 5px;
        font-size: 0.66rem;
    }

    .pf-panel {
        padding: 4px 12px 0;
    }

    .pf-rail {
        margin: 0 -12px;
        padding: 2px 12px 6px;
    }

    .pf-card {
        flex-basis: 124px;
    }

    .pf-details-body {
        padding-left: 14px;
    }

    .pf-medals {
        gap: 8px;
    }
}

@media (min-width: 769px) and (max-height: 720px) {
    .pf-hero {
        padding-top: 28px;
        padding-bottom: 46px;
    }

    .pf-avatar-wrap {
        width: 80px;
        height: 80px;
    }

    .pf-avatar {
        font-size: 2.5rem;
    }
}
