/* Профиль пользователя и настройки профиля.
   Раскладка зависит от ширины самого блока (container queries), а не экрана:
   так она одинаково работает при развернутом и свернутом меню сайта */

.uprofile,
.usettings {
    --p-accent: #0E7275;
    --p-accent-deep: #0B595B;
    --p-accent-soft: #E2EEEE;
    --p-ground: #F2F5F5;
    --p-surface: #FFFFFF;
    --p-border: #E3E9E9;
    --p-line: #EBEFEF;
    --p-input: #C9D4D4;
    --p-text: #142020;
    --p-muted: #5B6A69;
    --p-like: #D23B41;

    order: 2;
    width: 100%;
    box-sizing: border-box;
    background: var(--p-ground);
    color: var(--p-text);
    font-family: "Montserrat", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.uprofile *,
.usettings * {
    box-sizing: border-box;
}

.uprofile [hidden],
.usettings [hidden],
.avatar-cropper[hidden] {
    display: none !important;
}

.uprofile-vh {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.uprofile-icon {
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.uprofile-icon--filled {
    fill: currentColor;
    stroke: none;
}

/* ---------- Кнопки ---------- */

.uprofile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    font: 700 14px "Montserrat", system-ui, sans-serif;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}

.uprofile-btn--primary {
    background: var(--p-accent);
    color: #FFFFFF;
}

.uprofile-btn--primary:hover {
    background: var(--p-accent-deep);
    color: #FFFFFF;
}

.uprofile-btn--outline {
    height: 42px;
    border-color: var(--p-accent);
    background: var(--p-surface);
    color: var(--p-accent-deep);
    font-size: 13px;
}

.uprofile-btn--outline:hover {
    background: var(--p-accent-soft);
    color: var(--p-accent-deep);
}

.uprofile-btn--ghost {
    border-color: #D3DDDD;
    background: var(--p-surface);
    color: var(--p-text);
}

.uprofile-btn--ghost:hover {
    border-color: #B5C3C3;
    color: var(--p-text);
}

.uprofile-btn--small {
    height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    font-size: 13px;
}

.uprofile-btn:focus-visible,
.uprofile-tab:focus-visible,
.likes-privacy__option:focus-visible,
.usettings-add__toggle:focus-visible,
.usettings-add__item:focus-visible,
.usettings-icon-btn:focus-visible,
.usettings-back:focus-visible {
    outline: 2px solid var(--p-accent);
    outline-offset: 2px;
}

.uprofile-link {
    color: var(--p-accent-deep);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.uprofile-link:hover {
    text-decoration: underline;
}

.uprofile-only-narrow {
    display: none;
}

/* ---------- Профиль ---------- */

.uprofile {
    container: uprofile / inline-size;
    /* На странице профиля скрыта полоса под шапкой сайта: отступаем на высоту фиксированной шапки (60px) */
    padding: 88px 32px 48px;
}

.uprofile-hero,
.uprofile-content {
    max-width: 1180px;
    margin: 0 auto;
}

.uprofile-hero {
    --pad: 32px;
    --av: 136px;
    --overlap: 56px;

    overflow: hidden;
    border: 1px solid var(--p-border);
    border-radius: 20px;
    background: var(--p-surface);
}

.uprofile-cover {
    position: relative;
    height: 168px;
    overflow: hidden;
    background: var(--p-accent);
}

.uprofile-cover__pattern {
    position: absolute;
    right: -30px;
    top: -10px;
    fill: none;
    stroke: #FFFFFF;
    stroke-width: 2;
    opacity: .22;
}

/* "Текст в облаке" - мысленное облачко: пузырь справа от аватарки и два кружка, тянущиеся к ней */
.uprofile-bubble {
    position: absolute;
    left: calc(var(--pad) + var(--av) + 14px);
    bottom: calc(var(--overlap) - 4px);
    max-width: 340px;
    padding: 10px 16px;
    border-radius: 18px;
    background: #FFFFFF;
    color: var(--p-text);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}

.uprofile-bubble__dot {
    position: absolute;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .14);
}

.uprofile-bubble__dot--big {
    left: calc(var(--pad) + var(--av) - 8px);
    bottom: calc(var(--overlap) - 2px);
    width: 12px;
    height: 12px;
}

.uprofile-bubble__dot--small {
    left: calc(var(--pad) + var(--av) - 22px);
    bottom: calc(var(--overlap) - 15px);
    width: 7px;
    height: 7px;
}

.uprofile-head {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    column-gap: 24px;
    margin-top: calc(-1 * var(--overlap));
    padding: 0 var(--pad) 22px;
}

.uprofile-avatar {
    order: 1;
    flex: 0 0 auto;
    width: var(--av);
    height: var(--av);
    border: 5px solid #FFFFFF;
    border-radius: 50%;
    background: #FFFFFF;
    object-fit: cover;
    box-shadow: 0 6px 20px rgba(10, 30, 30, .18);
}

.uprofile-info {
    order: 2;
    flex: 1 1 320px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: calc(var(--overlap) + 14px);
}

.uprofile-actions {
    order: 3;
    flex: 0 0 auto;
    margin-left: auto;
    padding-top: calc(var(--overlap) + 14px);
}

.uprofile-name-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.uprofile-name {
    margin: 0;
    color: var(--p-text);
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.01em;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.uprofile-role {
    padding: 4px 10px;
    border-radius: 999px;
    background: #EEF2F2;
    color: #4A5857;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.uprofile-role--admin { background: #FDECEC; color: #B42318; }
.uprofile-role--mod_creator { background: #E4F5E8; color: #1E6B30; }
/* Оранжевый, как userstyleSIM_CREATOR (#FF7A00), но темнее для читаемости мелкого текста (контраст 4.8:1) */
.uprofile-role--sim_creator { background: #FFE8CC; color: #A34E00; }
.uprofile-role--top_uploader { background: #FFF5D1; color: #7A5600; }

.uprofile-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    color: var(--p-muted);
    font-size: 13px;
    font-weight: 500;
}

.uprofile-meta__item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.uprofile-meta__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #A3B1B0;
}

.uprofile-meta__dot--online {
    background: #2FA84F;
}

.uprofile-socials {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
}

.uprofile-social {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 13px 0 9px;
    border: 1px solid #DCE4E4;
    border-radius: 999px;
    background: #FFFFFF;
    color: var(--p-text);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: border-color .15s;
}

.uprofile-social:hover {
    border-color: #AFC0C0;
    color: var(--p-text);
}

.uprofile-social .social-icon {
    width: 18px;
    height: 18px;
}

/* Статистика */

.uprofile-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--p-line);
}

.uprofile-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 18px 24px;
}

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

.uprofile-stat__icon {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.uprofile-stat__icon--comments { background: #EAF1FE; color: #2F6FED; }
.uprofile-stat__icon--mods { background: #FFF3DB; color: #A35F00; }
.uprofile-stat__icon--downloads { background: #E4F5E8; color: #1E7B34; }
.uprofile-stat__icon--likes { background: #FDECEC; color: var(--p-like); }

.uprofile-stat__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.uprofile-stat__value {
    color: var(--p-text);
    font-size: 22px;
    font-weight: 800;
    line-height: 1.15;
    white-space: nowrap;
}

.uprofile-stat__label {
    color: var(--p-muted);
    font-size: 12px;
}

/* Вкладки */

.uprofile-tabs {
    display: flex;
    gap: 30px;
    padding: 0 var(--pad);
    border-top: 1px solid var(--p-line);
    overflow-x: auto;
    scrollbar-width: none;
}

.uprofile-tabs::-webkit-scrollbar {
    display: none;
}

.uprofile-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 54px;
    padding: 0 2px;
    border-bottom: 3px solid transparent;
    color: var(--p-muted);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}

.uprofile-tab:hover {
    color: var(--p-text);
}

.uprofile-tab--active,
.uprofile-tab--active:hover {
    border-bottom-color: var(--p-accent);
    color: var(--p-accent-deep);
}

.uprofile-tab__count {
    padding: 2px 8px;
    border-radius: 999px;
    background: #EEF2F2;
    color: #4A5857;
    font-size: 12px;
    font-weight: 700;
}

.uprofile-tab--active .uprofile-tab__count {
    background: var(--p-accent-soft);
    color: var(--p-accent-deep);
}

/* Содержимое вкладки */

.uprofile-content {
    margin-top: 20px;
    transition: opacity .2s;
}

.uprofile-content--loading {
    opacity: .45;
    pointer-events: none;
}

.uprofile-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.uprofile-section__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    min-height: 44px;
}

.uprofile-section__title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0;
    color: var(--p-text);
    font-size: 20px;
    font-weight: 800;
}

.uprofile-section__count {
    color: var(--p-muted);
    font-size: 14px;
    font-weight: 600;
}

.uprofile-section__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.likes-privacy {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.likes-privacy__label {
    color: var(--p-muted);
    font-size: 13px;
    font-weight: 600;
}

.likes-privacy__segments {
    display: inline-flex;
    padding: 3px;
    border-radius: 12px;
    background: #E4EBEB;
}

.likes-privacy__option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #4A5857;
    font: 700 13px "Montserrat", system-ui, sans-serif;
    cursor: pointer;
    transition: background-color .15s, color .15s;
}

.likes-privacy__option[aria-pressed="true"] {
    background: #FFFFFF;
    color: var(--p-accent-deep);
    box-shadow: 0 1px 3px rgba(16, 40, 40, .18);
}

.uprofile-note {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #FFF4DC;
    color: #7A4E00;
    font-size: 13px;
    font-weight: 600;
}

.uprofile-error {
    margin: 0;
    color: #B42318;
    font-size: 13px;
    font-weight: 600;
}

.uprofile-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 16px;
    border: 1px dashed #D3DDDD;
    border-radius: 16px;
    color: var(--p-muted);
    text-align: center;
}

.uprofile-empty p {
    max-width: 420px;
    margin: 0;
}

.uprofile-more {
    display: flex;
    justify-content: center;
    padding-top: 4px;
}

/* Сетка модов */

/* 4 мода в строке: при 5 картинки на десктопе получаются мелкими. 12 модов на странице = 3 полных ряда */
.uprofile-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.umod-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    color: var(--p-text);
    text-decoration: none;
}

.umod-card:hover {
    color: var(--p-text);
}

.umod-card__media {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 14px;
    background: #DCE4E4;
}

.umod-card__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s;
}

.umod-card:hover .umod-card__img {
    transform: scale(1.03);
}

.umod-card__cat {
    position: absolute;
    left: 8px;
    top: 8px;
    max-width: calc(100% - 16px);
    padding: 4px 9px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, .94);
    color: var(--p-text);
    font-size: 11px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.umod-card__likes {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(16, 26, 26, .74);
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 700;
}

.umod-card__heart {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
}

.umod-card__heart--filled {
    fill: #FF6B70;
    stroke: none;
}

.umod-card__body {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.umod-card__title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.umod-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    color: var(--p-muted);
    font-size: 12px;
}

.umod-card__author {
    font-weight: 700;
}

.umod-card__author.userstyleDEFAULT {
    color: #4A5857;
}

.umod-card__downloads {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

/* Списки: комментарии и история скачиваний */

.uprofile-list {
    overflow: hidden;
    border: 1px solid var(--p-border);
    border-radius: 16px;
    background: var(--p-surface);
}

.uprofile-comment,
.uprofile-history {
    display: flex;
    gap: 14px;
    padding: 16px 20px;
}

.uprofile-comment + .uprofile-comment,
.uprofile-history + .uprofile-history {
    border-top: 1px solid var(--p-line);
}

.uprofile-comment__img {
    display: block;
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
}

.uprofile-comment__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.uprofile-comment__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
}

.uprofile-comment__mod {
    color: var(--p-accent-deep);
    font-weight: 700;
    text-decoration: none;
}

.uprofile-comment__mod:hover {
    color: var(--p-accent-deep);
    text-decoration: underline;
}

.uprofile-comment__date {
    color: var(--p-muted);
    font-size: 12px;
}

.uprofile-comment__text {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.uprofile-history {
    align-items: center;
    padding-top: 12px;
    padding-bottom: 12px;
}

.uprofile-history__img {
    width: 72px;
    height: 54px;
    flex: 0 0 auto;
    border-radius: 10px;
    object-fit: cover;
}

.uprofile-history__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.uprofile-history__title {
    overflow: hidden;
    color: var(--p-text);
    font-weight: 700;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uprofile-history__title:hover {
    color: var(--p-accent-deep);
}

.uprofile-history__meta {
    color: var(--p-muted);
    font-size: 12px;
}

.uprofile-history__again {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 44px;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    background: var(--p-accent-soft);
    color: var(--p-accent-deep);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.uprofile-history__again:hover {
    background: #D2E5E5;
    color: var(--p-accent-deep);
}

/* Профиль: средняя ширина (планшет, узкий десктоп) */

@container uprofile (max-width: 919px) {
    .uprofile-hero {
        --pad: 24px;
        --av: 120px;
        --overlap: 50px;
    }

    .uprofile-cover {
        height: 150px;
    }

    .uprofile-name {
        font-size: 26px;
    }

    /* Уже, чтобы кнопка настроек оставалась в одной строке с именем */
    .uprofile-info {
        flex-basis: 220px;
    }

    /* Ячейкам статистики тесно: подпись уходит в подсказку при наведении, цифры меньше и без переносов */
    .uprofile-stat {
        padding: 14px 16px;
    }

    .uprofile-stat__value {
        font-size: 18px;
    }

    .uprofile-stat__label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .uprofile-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@container uprofile (max-width: 699px) {
    .uprofile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Профиль: узкая ширина (телефон) */

@container uprofile (max-width: 599px) {
    .uprofile-hero {
        --pad: 16px;
        --av: 96px;
        --overlap: 48px;
    }

    .uprofile-cover {
        height: 124px;
    }

    .uprofile-bubble {
        left: calc(var(--pad) + var(--av) + 10px);
        max-width: calc(100% - var(--pad) - var(--av) - 22px);
        font-size: 13px;
    }

    .uprofile-bubble__dot--big {
        left: calc(var(--pad) + var(--av) - 6px);
        width: 10px;
        height: 10px;
    }

    .uprofile-bubble__dot--small {
        left: calc(var(--pad) + var(--av) - 16px);
        bottom: calc(var(--overlap) - 13px);
        width: 6px;
        height: 6px;
    }

    .uprofile-head {
        column-gap: 14px;
        padding-bottom: 18px;
    }

    /* Информация уходит под аватарку, кнопка настроек остается справа от нее */
    .uprofile-info {
        order: 3;
        flex-basis: 100%;
        padding-top: 12px;
    }

    .uprofile-actions {
        order: 2;
        padding-top: calc(var(--overlap) + 8px);
    }

    .uprofile-name {
        font-size: 24px;
    }

    .uprofile-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .uprofile-stat + .uprofile-stat {
        border-left: 0;
    }

    .uprofile-stat:nth-child(even) {
        border-left: 1px solid var(--p-line);
    }

    .uprofile-stat:nth-child(n + 3) {
        border-top: 1px solid var(--p-line);
    }

    .uprofile-stat__label {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip: auto;
        white-space: normal;
    }

    /* 4 вкладки с числами не влезают: числа есть в статистике, "История скачиваний" -> "История" */
    .uprofile-tabs {
        justify-content: space-between;
        gap: 12px;
    }

    .uprofile-tab__count,
    .uprofile-only-wide {
        display: none;
    }

    .uprofile-only-narrow {
        display: inline;
    }

    .uprofile-section__title {
        font-size: 18px;
    }

    .uprofile-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .uprofile-comment,
    .uprofile-history {
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (max-width: 1023px) {
    .uprofile {
        padding: 84px 24px 40px;
    }
}

/* На телефоне карточка профиля во всю ширину экрана */
@media (max-width: 599px) {
    .uprofile {
        padding: 60px 0 32px;
    }

    .uprofile-hero {
        border: 0;
        border-radius: 0;
    }

    .uprofile-content {
        margin-top: 16px;
        padding: 0 12px;
    }
}

/* ---------- Настройки профиля ---------- */

.usettings {
    container: usettings / inline-size;
    padding: 28px 32px 48px;
}

.usettings-header,
.usettings-alert,
.usettings-layout {
    max-width: 1180px;
    margin-left: auto;
    margin-right: auto;
}

.usettings-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.usettings-back {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    margin-left: -8px;
    padding: 0 10px 0 6px;
    border-radius: 10px;
    color: var(--p-accent-deep);
    font-weight: 700;
    text-decoration: none;
}

.usettings-back:hover {
    background: var(--p-accent-soft);
    color: var(--p-accent-deep);
}

.usettings-title {
    margin: 0;
    color: var(--p-text);
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.01em;
    line-height: 1.15;
}

.usettings-subtitle {
    margin: 0;
    color: var(--p-muted);
}

.usettings-alert {
    margin-top: 20px;
    padding: 12px 16px;
    border-radius: 12px;
    background: #FDECEC;
    color: #B42318;
    font-weight: 600;
}

.usettings-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
    gap: 20px;
    margin-top: 20px;
}

.usettings-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.usettings-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    border: 1px solid var(--p-border);
    border-radius: 16px;
    background: var(--p-surface);
}

.usettings-card__head {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.usettings-card__title {
    margin: 0;
    color: var(--p-text);
    font-size: 17px;
    font-weight: 800;
}

.usettings-card__descr {
    margin: 0;
    color: var(--p-muted);
    font-size: 13px;
}

.usettings-avatar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 20px;
}

.usettings-avatar {
    width: 96px;
    height: 96px;
    flex: 0 0 auto;
    border: 4px solid #E4EBEB;
    border-radius: 50%;
    object-fit: cover;
}

.usettings-avatar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.usettings-file {
    position: relative;
}

.usettings-file input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.usettings-file:focus-within {
    outline: 2px solid var(--p-accent);
    outline-offset: 2px;
}

.usettings-hint {
    margin: 0;
    color: #1E6B30;
    font-size: 13px;
    font-weight: 600;
}

/* Ошибки показываются в блоке, к которому относятся */
.usettings-card--error {
    border-color: #F1B5B0;
}

.usettings-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 0;
    color: #B42318;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
}

/* Иконка "!" в круге: ошибку видно не только по цвету */
.usettings-error::before {
    content: '';
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1 5h2v7h-2zm0 9h2v2h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1 5h2v7h-2zm0 9h2v2h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.usettings-notice {
    margin: 0;
    color: #7A4E00;
    font-size: 13px;
    font-weight: 600;
}

.usettings-field:has(input[aria-invalid="true"]),
.usettings-social__input[aria-invalid="true"] {
    border-color: #D92D20;
}

.usettings-field:has(input[aria-invalid="true"]):focus-within,
.usettings-social__input[aria-invalid="true"]:focus {
    border-color: #D92D20;
    box-shadow: 0 0 0 3px rgba(217, 45, 32, .15);
}

.usettings-hint--error {
    color: #B42318;
}

.usettings-field {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--p-input);
    border-radius: 12px;
    background: #FFFFFF;
}

.usettings-field:focus-within,
.usettings-social__input:focus {
    border-color: var(--p-accent);
    box-shadow: 0 0 0 3px rgba(14, 114, 117, .15);
    outline: none;
}

.usettings-field__input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--p-text);
    font: 500 15px "Montserrat", system-ui, sans-serif;
}

.usettings-field__counter {
    flex: 0 0 auto;
    color: var(--p-muted);
    font-size: 12px;
    font-weight: 700;
}

.usettings-field__counter--full {
    color: #B42318;
}

.usettings-socials {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.usettings-social {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* Под полем ввода, с отступом на ширину иконки соцсети */
.usettings-social__error {
    flex-basis: 100%;
    margin-top: -4px;
    padding-left: 54px;
}

.usettings-social__icon {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.usettings-social__icon .social-icon {
    width: 22px;
    height: 22px;
}

.usettings-social__icon--telegram { background: #E6F5FC; }
.usettings-social__icon--boosty { background: #FEEEE7; }
.usettings-social__icon--vk { background: #E6F0FF; }
.usettings-social__icon--youtube { background: #FFE9E9; }

.usettings-social__input {
    /* Базовая ширина 0: иначе поле занимает "естественную" ширину и выталкивает корзину на новую строку */
    flex: 1 1 0;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--p-input);
    border-radius: 12px;
    background: #FFFFFF;
    color: var(--p-text);
    font: 500 14px "Montserrat", system-ui, sans-serif;
}

.usettings-icon-btn {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--p-muted);
    cursor: pointer;
}

.usettings-icon-btn:hover {
    background: #FDECEC;
    color: #B42318;
}

.usettings-add {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.usettings-add__toggle {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    border: 1px dashed var(--p-accent);
    border-radius: 12px;
    background: var(--p-accent-soft);
    color: var(--p-accent-deep);
    font: 700 14px "Montserrat", system-ui, sans-serif;
    cursor: pointer;
}

.usettings-add__menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.usettings-add__item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px 0 10px;
    border: 1px solid #D3DDDD;
    border-radius: 999px;
    background: #FFFFFF;
    color: var(--p-text);
    font: 700 13px "Montserrat", system-ui, sans-serif;
    cursor: pointer;
}

.usettings-add__item:hover {
    border-color: var(--p-accent);
}

.usettings-add__item .social-icon {
    width: 18px;
    height: 18px;
}

.usettings-switch-row {
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
}

.usettings-switch-row__icon {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #FDECEC;
    color: var(--p-like);
}

.usettings-switch-row__text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.usettings-switch-row__title {
    font-size: 15px;
    font-weight: 700;
}

.usettings-switch-row__hint {
    color: var(--p-muted);
    font-size: 13px;
}

/* Тумблер из обычного чекбокса */
.usettings-switch {
    position: relative;
    flex: 0 0 auto;
    width: 56px;
    height: 34px;
    margin: 0;
    border-radius: 999px;
    background: #B8C4C4;
    cursor: pointer;
    transition: background-color .2s;
    -webkit-appearance: none;
    appearance: none;
}

.usettings-switch::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .2s;
}

.usettings-switch:checked {
    background: var(--p-accent);
}

.usettings-switch:checked::after {
    transform: translateX(22px);
}

.usettings-switch:focus-visible {
    outline: 2px solid var(--p-accent);
    outline-offset: 2px;
}

.usettings-savebar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

.usettings-savebar__msg {
    margin-right: auto;
    color: var(--p-muted);
    font-size: 13px;
    font-weight: 600;
}

.usettings-savebar__msg--ok {
    color: #1E7B34;
}

/* Предпросмотр профиля */

.usettings-preview {
    position: sticky;
    top: 84px;
    overflow: hidden;
    border: 1px solid var(--p-border);
    border-radius: 16px;
    background: var(--p-surface);
}

.usettings-preview__label {
    padding: 12px 16px;
    border-bottom: 1px solid #EEF2F2;
    color: var(--p-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.usettings-preview__cover {
    position: relative;
    height: 100px;
    overflow: hidden;
    background: var(--p-accent);
}

.usettings-preview__cover .uprofile-cover__pattern {
    right: -20px;
    top: -8px;
}

.usettings-preview__bubble {
    position: absolute;
    left: 100px;
    bottom: 30px;
    max-width: calc(100% - 112px);
    padding: 8px 12px;
    border-radius: 14px;
    background: #FFFFFF;
    color: var(--p-text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
}

.usettings-preview__dot {
    position: absolute;
    border-radius: 50%;
    background: #FFFFFF;
}

.usettings-preview__dot--big {
    left: -16px;
    bottom: 4px;
    width: 9px;
    height: 9px;
}

.usettings-preview__dot--small {
    left: -24px;
    bottom: -5px;
    width: 6px;
    height: 6px;
}

.usettings-preview__body {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: -36px;
    padding: 0 16px 18px;
}

.usettings-preview__avatar {
    width: 72px;
    height: 72px;
    border: 4px solid #FFFFFF;
    border-radius: 50%;
    background: #FFFFFF;
    object-fit: cover;
    box-shadow: 0 4px 14px rgba(10, 30, 30, .16);
}

.usettings-preview__name {
    font-size: 18px;
    font-weight: 800;
}

.usettings-preview__socials {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.usettings-preview__social {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px 0 7px;
    border: 1px solid #DCE4E4;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.usettings-preview__social .social-icon {
    width: 16px;
    height: 16px;
}

.usettings-preview__privacy {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #EEF2F2;
    color: var(--p-muted);
    font-size: 12px;
    font-weight: 600;
}

/* Настройки: одна колонка - предпросмотр сверху, кнопки сохранения прилипают к низу экрана */

@container usettings (max-width: 899px) {
    .usettings-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .usettings-preview {
        position: relative;
        top: auto;
        order: -1;
    }

    .usettings-savebar {
        position: sticky;
        bottom: 0;
        z-index: 5;
        padding: 12px 16px;
        border: 1px solid var(--p-border);
        border-radius: 16px;
        background: #FFFFFF;
        box-shadow: 0 -6px 18px rgba(10, 30, 30, .08);
    }
}

@container usettings (max-width: 599px) {
    .usettings-title {
        font-size: 24px;
    }

    .usettings-card {
        padding: 16px;
    }
}

@media (max-width: 599px) {
    .usettings {
        padding: 16px 12px 24px;
    }
}

/* Модалка выбора квадратной области аватара (Cropper.js) */

.avatar-cropper {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .6);
    font-family: "Montserrat", system-ui, sans-serif;
}

.avatar-cropper__dialog {
    width: 100%;
    max-width: 560px;
    max-height: 100%;
    overflow: auto;
    padding: 24px;
    border-radius: 14px;
    background: #FFFFFF;
    color: #142020;
}

.avatar-cropper__title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.avatar-cropper__hint {
    margin: 6px 0 0;
    color: #5B6A69;
    font-size: 13px;
}

.avatar-cropper__area {
    height: min(60vh, 440px);
    margin-top: 16px;
    overflow: hidden;
    border-radius: 8px;
    background: #2B2B2B;
}

.avatar-cropper__area img {
    display: block;
    max-width: 100%;
}

/* Граница выбранного квадрата - пунктир */
.avatar-cropper .cropper-view-box {
    outline: 2px dashed #FFFFFF;
    outline-offset: -1px;
}

.avatar-cropper .cropper-line {
    background-color: transparent;
}

.avatar-cropper .cropper-point,
.avatar-cropper .cropper-point.point-se {
    width: 10px;
    height: 10px;
    background-color: #31B0B5;
    opacity: 1;
}

.avatar-cropper .cropper-dashed {
    border-color: rgba(255, 255, 255, .7);
}

.avatar-cropper__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

@media (max-width: 599px) {
    .avatar-cropper__dialog {
        padding: 18px;
    }

    .avatar-cropper__area {
        height: min(55vh, 340px);
    }
}
