.profile-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    gap: 40px;
    /* overflow-y: auto; Removed to prevent double scrollbar */
    /* height: 100vh; Removed to allow body scroll */
    min-height: 100vh;
    /* Ensure it covers screen but grows */
}

.profile-header {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    flex-wrap: wrap;
}

.user-main {
    display: flex;
    align-items: center;
    gap: 25px;
}

.avatar-large {
    width: 130px;
    height: 130px;
    background: linear-gradient(135deg, var(--primary), #2ecc71);
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4.5rem;
    color: white;
    box-shadow: 0 10px 20px rgba(52, 152, 219, 0.2);
    transform: rotate(-3deg);
    position: relative;
    /* Ensure relative positioning for overlay */
}

.edit-icon-overlay {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    /* Flex display toggled by JS */
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    border: 2px solid var(--card-bg);
    transform: rotate(3deg);
    transition: transform 0.2s;
}

.avatar-large:hover .edit-icon-overlay {
    transform: scale(1.1) rotate(3deg);
}

.user-identity h1 {
    margin: 0;
    font-size: 2.2rem;
    color: var(--text-main);
    font-weight: 800;
}

.badge-row {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.prof-badge {
    padding: 6px 16px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.badge-lvl {
    background: #f1c40f;
}

.badge-streak {
    background: #e67e22;
}

.badge-score {
    background: var(--primary);
}

.header-progress {
    min-width: 250px;
    flex-grow: 1;
    max-width: 350px;
}

.xp-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: bold;
}

.xp-bar-outer {
    height: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

body.dark-mode .xp-bar-outer {
    background: rgba(255, 255, 255, 0.05);
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #2ecc71);
    width: 0%;
    transition: width 1s cubic-bezier(0.17, 0.67, 0.83, 0.67);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 25px;
    text-align: left;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid transparent;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 15px 40px rgba(52, 152, 219, 0.1);
}

.stat-icon-circle {
    width: 60px;
    height: 60px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(52, 152, 219, 0.08);
    color: var(--primary);
}

.stat-card:nth-child(2) .stat-icon-circle {
    background: rgba(46, 204, 113, 0.08);
    color: #2ecc71;
}

.stat-card:nth-child(3) .stat-icon-circle {
    background: rgba(155, 89, 182, 0.08);
    color: #9b59b6;
}

.stat-card:nth-child(4) .stat-icon-circle {
    background: rgba(230, 126, 34, 0.08);
    color: #e67e22;
}

.stat-data {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: bold;
}

.section-title {
    font-size: 1.4rem;
    color: var(--secondary);
    margin-bottom: 25px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
}

.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
}

.achievement-card {
    background: var(--card-bg);
    padding: 25px 15px;
    border-radius: 22px;
    text-align: center;
    opacity: 0.4;
    filter: grayscale(1);
    border: 2px solid transparent;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.achievement-card.unlocked {
    opacity: 1;
    filter: none;
    border-color: #f1c40f;
    background: linear-gradient(135deg, var(--card-bg), rgba(241, 196, 15, 0.03));
    transform: scale(1.05);
}

.achievement-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.achievement-card strong {
    font-size: 0.85rem;
    display: block;
    color: var(--text-main);
}

.back-btn {
    position: fixed;
    top: 25px;
    left: 25px;
    background: var(--card-bg);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: 15px;
    text-decoration: none;
    font-weight: bold;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateX(-5px);
}

.texts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.text-item {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.text-content {
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.4;
}

.text-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.text-type {
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--primary);
    background: rgba(52, 152, 219, 0.1);
    padding: 4px 10px;
    border-radius: 8px;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .profile-header {
        text-align: center;
        flex-direction: column;
        padding: 30px;
    }

    .user-main {
        flex-direction: column;
    }

    .badge-row {
        justify-content: center;
    }

    .header-progress {
        width: 100%;
    }
}

/* Modal and Tab styles are now in main.css */

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
}

.avatar-option {
    font-size: 2.5rem;
    background: rgba(0, 0, 0, 0.03);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
}

.avatar-option:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.cancel-btn {
    background: var(--text-muted);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 15px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
}

/* Theme Toggle Button for Profile */
#profile-theme-toggle {
    position: fixed;
    top: 25px;
    right: 25px;
    background: var(--card-bg);
    border: none;
    font-size: 1.5rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.3s;
}

#profile-theme-toggle:hover {
    transform: rotate(15deg) scale(1.1);
    background: var(--button-hover);
}

/* Generic Action Button for Modals (Themed) */
.modal-action-btn {
    background: var(--primary);
    color: white;
    font-weight: bold;
    font-size: 1rem;
    padding: 12px 30px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    transition: all 0.2s;
    margin-top: 15px;
}

.modal-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
    filter: brightness(1.1);
}