.profile-container {
    max-width: 600px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar-wrapper {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.avatar-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.avatar-edit-btn {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--teal-900);
    border: 2px solid var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    color: #fff;
}

.username-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-family: var(--font-d);
    font-size: 17px;
    font-weight: 600;
    color: var(--text-1);
}

.edit-pen-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-3);
    line-height: 1;
}

.edit-pen-btn:hover {
    color: var(--text-2);
}

.username-edit-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.username-input {
    width: 180px;
}

.status-msg {
    font-family: var(--font-m);
    font-size: 13px;
    margin: 0;
    color: var(--text-2);
}

.modal-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(4, 52, 44, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--notch);
    padding: 1.5rem;
    width: 340px;
    max-width: 90vw;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.modal-header h6 {
    font-family: var(--font-d);
    color: var(--text-1);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-3);
}

.modal-close-btn:hover {
    color: var(--text-2);
}

.modal-hint {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 12px;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
    min-height: 60px;
}

.avatar-grid-empty {
    grid-column: 1 / -1;
    font-size: 13px;
    color: var(--text-3);
}

.modal-msg {
    margin-top: 0.5rem;
    margin-bottom: 0;
    font-size: 13px;
    color: var(--text-2);
}

.avatar-option {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.15s;
}

.avatar-option--selected {
    border-color: var(--teal-600);
}

.panel-narrow {
    width: fit-content;
    max-width: 100%;
    border: 2px solid var(--teal-200);
    border-radius: var(--notch);
}

@media (max-width: 768px) {

    .profile-header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .profile-header>div:last-child {
        flex: 0 1 auto;
    }

    .panel-narrow {
        width: fit-content;
        max-width: 100%;
        border: 2px solid var(--teal-200);
        border-radius: var(--notch);
    }

    .username-row {
        flex-wrap: nowrap;
        max-width: 100%;
    }

    .username-row>span:first-child {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .edit-pen-btn {
        flex-shrink: 0;
    }

    .username-edit-row {
        flex-wrap: nowrap;
        max-width: 100%;
    }

    .username-input {
        width: auto;
        max-width: 45%;
        flex: 1 1 auto;
    }
}