/* Profile experience: clear hierarchy, compact cards and mobile-first spacing. */
:root {
    --profile-ink: #0f172a;
    --profile-muted: #64748b;
    --profile-blue: #2563eb;
    --profile-blue-dark: #1d4ed8;
    --profile-border: #dce6f3;
    --profile-surface: #ffffff;
    --profile-gutter: max(1rem, env(safe-area-inset-left));
}

html {
    background: #f4f7fc;
}

body {
    min-width: 0;
    background:
        radial-gradient(circle at 100% 0%, rgba(191, 219, 254, 0.5), transparent 26rem),
        #f4f7fc;
    color: var(--profile-ink);
}

.profile-container {
    min-height: 100dvh !important;
    padding:
        calc(0.85rem + env(safe-area-inset-top))
        var(--profile-gutter)
        calc(2rem + env(safe-area-inset-bottom)) !important;
    background: transparent !important;
}

.profile-content {
    width: min(100%, 68rem);
    max-width: none !important;
    margin: 0 auto !important;
}

.profile-topbar {
    position: relative;
    z-index: 5;
    margin: 0 0 1rem !important;
    padding: 0.55rem;
    flex-wrap: nowrap !important;
    gap: 0.55rem !important;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, 0.84);
    box-shadow: 0 10px 28px rgba(30, 64, 175, 0.09);
    backdrop-filter: blur(14px);
}

.profile-topbar-actions {
    min-width: 0;
    gap: 0.4rem;
}

.profile-topbar .btn-back {
    flex: 0 0 2.75rem;
    width: 2.75rem !important;
    height: 2.75rem !important;
    min-height: 2.75rem;
    margin: 0 !important;
    padding: 0 !important;
    justify-content: center;
    color: #28465f !important;
    border: 1px solid #d8e5ef;
    border-radius: 0.85rem !important;
    background: #f3f7fa !important;
    box-shadow: none;
}

.profile-topbar .btn-back span {
    display: none;
}

.profile-topbar .btn-back i {
    margin: 0 !important;
}

.profile-admin-button {
    min-height: 2.75rem;
    margin: 0 !important;
    padding: 0 0.8rem !important;
    border-radius: 0.85rem !important;
    font-size: 0.76rem !important;
    box-shadow: none !important;
}

.profile-level-chip {
    min-width: 0;
    margin-left: auto !important;
    padding: 0.35rem 0.75rem 0.35rem 0.35rem !important;
    gap: 0.55rem !important;
    border-color: #dbe7f3 !important;
    box-shadow: none !important;
}

.profile-level-chip > div:first-child {
    flex: 0 0 2.25rem;
    width: 2.25rem !important;
    height: 2.25rem !important;
    box-shadow: none !important;
}

.profile-level-chip > div:last-child {
    min-width: clamp(6.8rem, 30vw, 9rem) !important;
}

.profile-layout-grid {
    display: grid !important;
    margin: 0 0 1rem !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1rem !important;
}

.profile-right-col {
    order: -1;
    padding: 1.25rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    border: 1px solid var(--profile-border);
    border-radius: 1.5rem;
    background:
        radial-gradient(circle at 50% 0%, rgba(219, 234, 254, 0.85), transparent 11rem),
        var(--profile-surface);
    box-shadow: 0 14px 34px rgba(30, 64, 175, 0.1);
}

.profile-avatar-wrap {
    margin: 0 !important;
}

.profile-avatar-wrap > div {
    padding: 0.25rem !important;
}

.profile-avatar-image {
    width: 5.5rem !important;
    height: 5.5rem !important;
    border: 3px solid #fff !important;
    outline: 3px solid #3b82f6;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.22) !important;
}

.profile-identity {
    width: 100%;
    text-align: center;
}

.profile-identity h1 {
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    color: var(--profile-ink);
    font-size: clamp(1.25rem, 6vw, 1.7rem);
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-rank-badge {
    display: inline-flex;
    min-height: 2rem;
    margin-top: 0.45rem;
    padding: 0.35rem 0.75rem;
    align-items: center;
    gap: 0.4rem;
    color: #a16207;
    border: 1px solid #fde68a;
    border-radius: 999px;
    background: #fffbeb;
    font-size: 0.76rem;
    font-weight: 700;
}

.profile-stat-grid {
    display: grid !important;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem !important;
}

.profile-stat-grid .stat-pill {
    min-width: 0;
    padding: 0.7rem 0.35rem !important;
    border-color: #e2e8f0 !important;
    border-radius: 1rem !important;
    box-shadow: none !important;
}

.profile-stat-grid .stat-pill > div:first-child {
    overflow: hidden;
    font-size: 0.68rem !important;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-stat-grid .stat-pill > div:last-child {
    margin-top: 0.15rem;
    font-size: 1.05rem !important;
    line-height: 1.2;
}

.profile-daily-wrap {
    margin-top: 0.15rem;
}

.daily-checkin-card,
.achievements-card {
    margin: 0 !important;
    padding: 1rem !important;
    border-radius: 1.15rem !important;
    box-shadow: none !important;
}

.daily-checkin-card {
    background: linear-gradient(135deg, #059669, #0f766e) !important;
}

.achievements-card {
    background: linear-gradient(135deg, #7c3aed, #5b21b6) !important;
}

.checkin-widget-icon {
    margin-bottom: 0.35rem !important;
    font-size: 1.8rem !important;
}

.checkin-widget-title,
.achievements-title {
    margin-bottom: 0.25rem !important;
    font-size: 1rem !important;
}

.checkin-widget-streak {
    margin-bottom: 0.45rem !important;
    font-size: 0.78rem !important;
}

.checkin-widget-points {
    font-size: 1.65rem !important;
}

.checkin-widget-label {
    margin-bottom: 0.7rem !important;
    font-size: 0.72rem !important;
}

.btn-checkin-widget,
.btn-view-achievements {
    min-height: 2.75rem;
    padding: 0.55rem 1rem !important;
    border-radius: 0.85rem !important;
    font-size: 0.82rem !important;
}

.badges-preview {
    margin: 0.65rem 0 !important;
}

.badge-icon-only {
    font-size: 2rem !important;
}

.profile-avatar-column {
    gap: 0.7rem !important;
}

.avatar-viewer-container {
    min-height: 10.5rem !important;
    padding: 1.25rem !important;
    border: 1px dashed #c6d5e5;
    border-radius: 1.25rem !important;
    background:
        radial-gradient(circle at 50% 0%, rgba(219, 234, 254, 0.8), transparent 9rem),
        #f8fafc !important;
    box-shadow: none !important;
}

.avatar-viewer-container > div:first-child {
    margin-bottom: 0.55rem !important;
}

.avatar-viewer-container > div:first-child i {
    font-size: 2.25rem !important;
}

.avatar-viewer-container h3 {
    margin: 0 !important;
    font-size: 0.92rem;
}

.avatar-viewer-container > p {
    display: none;
}

.avatar-viewer-container > div:last-child {
    display: none;
}

.profile-wardrobe-button {
    min-height: 3rem;
    padding: 0.65rem 1rem !important;
    border-color: #bfdbfe !important;
    border-radius: 1rem !important;
    background: #eff6ff !important;
    color: var(--profile-blue) !important;
    box-shadow: none !important;
    font-family: inherit;
    touch-action: manipulation;
}

.profile-card {
    margin: 0 0 1rem !important;
    overflow: hidden;
    border: 1px solid var(--profile-border) !important;
    border-radius: 1.4rem !important;
    background: var(--profile-surface) !important;
    box-shadow: 0 12px 32px rgba(30, 64, 175, 0.08) !important;
}

.checkins-section {
    padding: 1rem !important;
}

.checkins-title {
    display: flex;
    margin: 0 0 0.8rem !important;
    padding: 0 0 0.75rem !important;
    align-items: center;
    gap: 0.55rem;
    border-bottom-width: 1px !important;
    font-size: 1.05rem !important;
}

.checkins-title i {
    display: grid;
    flex: 0 0 2rem;
    width: 2rem;
    height: 2rem;
    place-items: center;
    color: var(--profile-blue);
    border-radius: 0.65rem;
    background: #eff6ff;
    font-size: 0.85rem;
}

.checkin-list {
    gap: 0.65rem !important;
}

.checkin-item {
    display: grid !important;
    padding: 0.8rem !important;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.7rem !important;
    border: 1px solid #e4ebf3;
    border-left: 3px solid var(--profile-blue) !important;
    border-radius: 0.9rem !important;
    background: #f8fafc !important;
}

.checkin-icon {
    font-size: 1.2rem !important;
}

.checkin-name {
    overflow: hidden;
    font-size: 0.88rem !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.checkin-date {
    font-size: 0.7rem !important;
    line-height: 1.45;
}

.checkin-points {
    font-size: 0.9rem !important;
}

.no-checkins {
    padding: 2rem 1rem !important;
    font-size: 0.85rem !important;
}

.history-grid {
    display: grid !important;
    margin-top: 0.75rem !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.6rem !important;
}

.history-grid > div {
    min-width: 0;
    padding: 0.8rem !important;
    border-radius: 0.9rem !important;
    background: #f8fafc !important;
}

.profile-logout-wrap {
    margin-top: 0.25rem !important;
}

.profile-logout-button {
    min-height: 3rem;
    max-width: none !important;
    padding: 0.65rem 1rem !important;
    border-radius: 1rem !important;
    background: #fff7f7 !important;
    box-shadow: none !important;
    font-family: inherit;
    font-size: 0.88rem !important;
    touch-action: manipulation;
}

.loading-state {
    min-height: 70dvh;
    display: grid;
    place-content: center;
    gap: 0.75rem;
}

.loading-spinner {
    font-size: 2rem !important;
}

@media (min-width: 48rem) {
    .profile-container {
        padding-inline: 2rem !important;
    }

    .profile-topbar {
        padding: 0.7rem;
    }

    .profile-topbar .btn-back {
        width: auto !important;
        padding: 0 1rem !important;
        flex-basis: auto;
        gap: 0.5rem;
    }

    .profile-topbar .btn-back span {
        display: inline;
    }

    .profile-layout-grid {
        grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr) !important;
        align-items: stretch;
    }

    .profile-right-col {
        order: initial;
        padding: 1.5rem !important;
    }

    .avatar-viewer-container {
        min-height: 24rem !important;
    }

    .avatar-viewer-container > p {
        display: block;
    }

    .avatar-viewer-container > div:last-child {
        display: block;
    }

    .history-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .level-progress-fill::after,
    .loading-spinner,
    .avatar-viewer-container i {
        animation: none !important;
    }

    .profile-card,
    .checkin-item,
    .profile-wardrobe-button {
        transition: none !important;
    }
}
/* Mobile profile renovation: compact identity, thumb-friendly actions and clear hierarchy. */
.profile-topbar-title {
    min-width: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.profile-topbar-title strong {
    overflow: hidden;
    color: var(--profile-ink);
    font-size: 0.92rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-topbar-title span {
    margin-top: 0.15rem;
    color: var(--profile-muted);
    font-size: 0.66rem;
}

.profile-stat-grid .stat-pill > i {
    display: grid;
    width: 1.65rem;
    height: 1.65rem;
    margin: 0 auto 0.35rem;
    place-items: center;
    border-radius: 0.55rem;
    font-size: 0.72rem;
}

.profile-stat-grid .stat-pill-total > i { color: #2563eb; background: #dbeafe; }
.profile-stat-grid .stat-pill-month > i { color: #0284c7; background: #e0f2fe; }
.profile-stat-grid .stat-pill-coins > i { color: #d97706; background: #fef3c7; }

@media (max-width: 47.99rem) {
    body {
        background:
            radial-gradient(circle at 100% 0%, rgba(191, 219, 254, 0.72), transparent 20rem),
            linear-gradient(180deg, #f8fbff 0%, #f4f7fc 42%, #eef3f9 100%);
    }

    .profile-container { padding-top: calc(0.55rem + env(safe-area-inset-top)) !important; }

    .profile-topbar {
        position: sticky;
        top: calc(0.35rem + env(safe-area-inset-top));
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding: 0.45rem !important;
        border-radius: 1rem;
        box-shadow: 0 8px 24px rgba(30, 64, 175, 0.1);
    }

    .profile-topbar-actions {
        grid-column: 1;
        grid-row: 1;
        display: flex !important;
    }

    .profile-topbar-actions:has(.profile-admin-button) + .profile-topbar-title {
        display: none;
    }

    .profile-admin-button {
        width: 2.75rem;
        padding: 0 !important;
        justify-content: center;
        font-size: 0 !important;
    }

    .profile-admin-button i { font-size: 0.82rem; }

    .profile-topbar-title {
        grid-column: 2;
        grid-row: 1;
        padding: 0 0.6rem;
    }

    .profile-level-chip {
        grid-column: 3;
        grid-row: 1;
        padding-right: 0.5rem !important;
    }

    .profile-level-chip > div:last-child {
        min-width: 5.4rem !important;
        width: 5.4rem;
    }

    .profile-layout-grid { gap: 0.75rem !important; }

    .profile-right-col {
        display: grid !important;
        grid-template-columns: 4.75rem minmax(0, 1fr);
        padding: 1rem !important;
        align-items: center !important;
        column-gap: 0.9rem !important;
        row-gap: 0.85rem !important;
        border-radius: 1.3rem;
        background:
            radial-gradient(circle at 15% 0%, rgba(191, 219, 254, 0.88), transparent 10rem),
            var(--profile-surface);
    }

    .profile-avatar-wrap { grid-column: 1; grid-row: 1; }

    .profile-avatar-image {
        width: 4.5rem !important;
        height: 4.5rem !important;
        outline-width: 2px;
    }

    .profile-identity {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
        text-align: left;
    }

    .profile-identity h1 { font-size: clamp(1.18rem, 6vw, 1.55rem); }
    .profile-rank-badge { margin-top: 0.35rem; }

    .profile-stat-grid,
    .profile-daily-wrap { grid-column: 1 / -1; }

    .profile-stat-grid { gap: 0.45rem !important; }

    .profile-stat-grid .stat-pill {
        padding: 0.65rem 0.25rem !important;
        border-radius: 0.9rem !important;
    }

    .profile-stat-grid .stat-pill > div:first-of-type { font-size: 0.62rem !important; }
    .profile-stat-grid .stat-pill > div:last-child { font-size: 1rem !important; }
    .profile-avatar-column { gap: 0 !important; }
    .avatar-viewer-container { display: none !important; }

    .profile-wardrobe-button {
        position: relative;
        justify-content: flex-start !important;
        min-height: 3.4rem;
        padding: 0.75rem 3rem 0.75rem 1rem !important;
        background: linear-gradient(135deg, #eff6ff, #eef2ff) !important;
        text-align: left;
    }

    .profile-wardrobe-button::after {
        content: '\f054';
        position: absolute;
        right: 1rem;
        display: grid;
        width: 1.8rem;
        height: 1.8rem;
        place-items: center;
        border-radius: 50%;
        background: #fff;
        font-family: 'Font Awesome 6 Free';
        font-size: 0.65rem;
        font-weight: 900;
    }

    .daily-checkin-card,
    .achievements-card { text-align: left !important; }

    .badges-preview { justify-content: flex-start !important; }

    .btn-checkin-widget,
    .btn-view-achievements { width: 100%; }

    .profile-card { border-radius: 1.2rem !important; }
    .checkin-item { min-height: 3.75rem; }

    .profile-logout-button {
        min-height: 2.9rem;
        border-style: dashed !important;
    }

    .profile-right-col,
    .profile-avatar-column,
    .profile-card,
    .profile-logout-wrap { animation: profile-rise 0.5s both; }

    .profile-avatar-column { animation-delay: 0.06s; }
    .profile-card:nth-of-type(1) { animation-delay: 0.1s; }
    .profile-card:nth-of-type(2) { animation-delay: 0.14s; }
    .profile-logout-wrap { animation-delay: 0.18s; }
}

@keyframes profile-rise {
    from { opacity: 0; transform: translateY(0.75rem); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .profile-right-col,
    .profile-avatar-column,
    .profile-card,
    .profile-logout-wrap { animation: none !important; }
}

/* Mobile top bar: keep EXP on one line and center the admin glyph. */
@media (max-width: 47.99rem) {
    .profile-admin-button {
        display: inline-grid !important;
        flex: 0 0 2.75rem;
        width: 2.75rem !important;
        height: 2.75rem;
        align-items: center !important;
        justify-content: center !important;
        place-items: center;
        gap: 0 !important;
        line-height: 1 !important;
    }

    .profile-admin-button i {
        display: block;
        width: 1em;
        margin: 14px !important;
        font-size: 0.9rem !important;
        line-height: 1 !important;
        text-align: center;
    }

    .profile-level-chip > div:last-child {
        width: 6.75rem !important;
        min-width: 6.75rem !important;
    }

    .profile-level-chip > div:last-child > div:first-child,
    .profile-level-chip > div:last-child span {
        white-space: nowrap;
    }
}
