.chat_open span {
    position: absolute;
    top: -10px;
    right: -10px;
    font-weight: 700;
    width: 25px;
    height: 25px;
    display: flex;
    border-radius: 50%;
    color: var(--span);
    border: solid 2px var(--span);
    font-size: 12px;
    background-color: var(--bg);
    justify-content: center;
    align-items: center;
}
.chat_peoples {
    display: flex;
    gap: 5px;
    height: 25px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}
.chat_peoples .ava {
    cursor: pointer;
    width: 25px;
    height: 25px;
    border-radius: 6px;
    opacity: .6;
    transition: .5s;
    object-fit: cover;
}
.chat_peoples .ava:hover {
    opacity: 1;
}
.block-chat-back {
    background-color: var(--card);
    padding: 8px 8px 8px 8px;
    border-radius: var(--br-16);
    overflow: visible;
    height: max-content;
    position: relative;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}
.chat_footer_send {
    display: flex;
    background-color: var(--bg);
    padding: 10px;
    gap: 8px;
    border-radius: var(--br-16);
    position: relative;
    align-items: center;
}
.chat_actions {
    position: static;
    display: flex;
    gap: 8px;
    height: 40px;
    align-items: center;
    margin-left: 0;
    background-color: var(--card);
    border-radius: 6px;
    padding: 0 8px;
}
.chat_footer_send > form {
    width: 100%;
}
.chat_action_btn { cursor: pointer; position: static; display: flex; height: 40px; transition: .5s; align-items: center; user-select: none; }
.chat_smile_btn, .chat_users_btn, .chat_gear_btn { 
    /* Стили для кнопок чата */
}
/* Скрыть исходный смайл до переноса в .chat_actions, чтобы не было мигания и пробела */
#chat_menu_smile { display: none; }
.chat_actions #chat_menu_smile { display: flex; }
.chat_action_btn svg {
    fill: var(--text-custom);
    transition: .5s;
    width: 20px;
    height: 20px;
    user-select: none;
    z-index: 1;
}
.chat_action_btn:hover svg {
    fill: var(--span);
}
.chat_menu_smile {
    opacity: 0;
    pointer-events: none;
    bottom: 0px;
    right: 10px;
    display: flex;
    position: absolute;
    width: 290px;
    flex-wrap: wrap;
    border-radius: 6px;
    padding: 10px;
    user-select: none;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    background-color: var(--card);
    z-index: 10001;
    transition: opacity 0.3s, bottom 0.3s;
}
.chat_menu_smile.active {
    opacity: 1;
    pointer-events: auto;
    bottom: 62px;
}
.chat_menu_users,
.chat_menu_settings {
    opacity: 0;
    pointer-events: none;
    bottom: 0px;
    right: 10px;
    display: flex;
    position: absolute;
    width: 290px;
    flex-direction: column;
    align-items: center;
    border-radius: 6px;
    padding: 10px;
    user-select: none;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    background-color: var(--card);
    z-index: 10001;
    transition: opacity 0.3s, bottom 0.3s;
}
.chat_menu_users.active,
.chat_menu_settings.active { opacity: 1; pointer-events: auto; bottom: 62px; }
.chat_menu_header { font-weight: 700; margin-bottom: 10px; text-align: center; width: 100%; font-size: 14px; color: var(--text-custom); }
.chat_menu_users .users_list { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-height: 200px; overflow: auto; width: 100%; }
.chat_menu_settings .chat_settings_content { display: flex; justify-content: center; width: 100%; }
.chat_menu_settings label[for="chat_checkbox_call"] { font-size: 12px; }
/* Таблица настроек: 2 колонки (подпись / ползунок) */
.chat_settings_table { display: flex; flex-direction: column; gap: 12px; width: 100%; padding: 0 12px; }
.chat_settings_table .row { display: grid; grid-template-columns: 1fr 1fr; align-items: center; }
.chat_settings_table .label { font-size: 12px; font-weight: 700; text-align: center; color: var(--text-custom); }
.chat_settings_table .control { display: flex; align-items: center; justify-content: center; gap: 8px; }
/* Скрыть чат (blur) */
.chat_blur_enabled #chat_main_content { filter: blur(6px); pointer-events: none; }

/* Скрыть старый блок онлайна на странице (перенесён в меню) */
.block-chat-back > .block-chat-online { display: none !important; }

.chat_menu_users .block-chat-online { display: flex !important; justify-content: center; }
.chat_menu_users .block-chat-online .chat_peoples { height: auto; margin: 0; justify-content: center; }
.chat_menu_smile .smiley_js {
    cursor: pointer;
    width: 30px;
    height: 30px;
    font-size: 20px;
    opacity: .5;
    transition: .5s;
    display: flex;
    justify-content: center;
    align-items: center;
}
.chat_menu_smile .smiley_js:hover {
    opacity: 1;
}
.block-chat-my {
    display: flex;
    gap: 15px;
    background-color: var(--card);
    margin-bottom: 30px;
    padding: 15px;
    border-radius: 6px;
    align-items: center;
    position: relative;
}
.block-chat-my h5 {
    display: grid;
    gap: 5px;
}
.block-chat-my .block-chat-ava-my {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    opacity: .6;
    transition: .5s;
    object-fit: cover;
}
.block-chat-my .block-chat-ava-my:hover {
    opacity: 1;
}
.block-chat-my h5 div {
    font-size: 8px;
    color: var(--text-custom);
}
.onlines_mess div h4 {
    cursor: pointer;
    transition: .5s;
}
.onlines_mess div h4:hover {
    color: var(--span);
}
.block-chat-back > h2 {
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}
#chat_main_content {
    display: flex;
    width: 100%;
    gap: 2px;
    padding: 8px 8px 8px 8px; /* синхронизировано с .block-chat-back */
    margin: 0 0 6px 0; /* немного увеличил нижний отступ для визуального воздуха */
    height: 218px;
    overflow: auto;
    background-color: var(--bg);
    border-radius: var(--br-16);
    flex-direction: column;
}
#chat_main_content::-webkit-scrollbar {
    width: 4px;
}
#chat_main_content::-webkit-scrollbar-track {
    background: transparent;
}
#chat_main_content::-webkit-scrollbar-thumb {
    background: var(--text-custom);
    border-radius: 2px;
    opacity: 0.3;
}
#chat_main_content::-webkit-scrollbar-thumb:hover {
    opacity: 0.6;
}
.chat_footer_send > button {
    cursor: pointer;
    height: 40px;
    border-radius: 6px;
    width: 40px;
    transition: .5s;
    background-color: var(--card);
    color: var(--text-custom);
}
.chat_footer_send > button > svg {
    transition: .5s;
    fill: var(--text-custom);
    width: 15px;
    height: 15px;
}
.chat_footer_send > button:hover {
    color: var(--bg);
    background-color: var(--span);
}
.chat_footer_send > button:hover svg {
    fill: var(--bg);
}
.chat_line {
    font-weight: 700;
    color: var(--text-custom);
    font-size: 10px;
    display: flex;
    margin: 10px 5px;
    justify-content: space-between;
    align-items: center;
}
#chat_send_message > textarea {
    outline: 0;
    resize: none;
    float: left;
    min-height: 40px;
    max-height: 100px;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 6px;
    line-height: 1.5;
    padding: 9px 15px 9px 15px;
    word-wrap: break-word;
    -webkit-box-sizing: border-box;
    background-color: var(--card);
    box-sizing: border-box;
    border: 0;
    color: var(--link-second-navbar-color);
    overflow-wrap: break-word;
}
[contentEditable=true]:empty:not(:focus):before {
    content: attr(data-text);
    color: var(--text-custom);
}
div:empty:before {
    content: attr(data-text);
    color: var(--text-custom);
}
.chat_message {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 2px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.chat_message:last-child {
    border-bottom: none;
}
.chat_message_my {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 2px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.chat_message_my:last-child {
    border-bottom: none;
}
.chat_message .padding, .chat_message_my .padding {
    padding: 6px 0;
    background-color: transparent;
    border-radius: 0;
    position: relative;
    display: flex;
    gap: 12px;
    width: 100%;
}
.chat_message .avatar_wrap, .chat_message_my .avatar_wrap {
    flex-shrink: 0;
}
.chat_message .avatar_wrap > a > img, .chat_message_my .avatar_wrap > a > img {
    width: 50px; /* увеличен размер аватарки */
    height: 50px;
    cursor: pointer;
    border-radius: 6px;
    opacity: .6;
    transition: .5s;
    object-fit: cover;
}
.chat_message .avatar_wrap > a > img:hover, .chat_message_my .avatar_wrap > a > img:hover {
    opacity: 1;
}
.chat_message .chat_info, .chat_message_my .chat_info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.chat_message .chat_header, .chat_message_my .chat_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.chat_message .chat_nickname_role, .chat_message_my .chat_nickname_role {
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat_message .chat_meta, .chat_message_my .chat_meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: var(--text-custom);
}
.chat_message .chat_message_content {
    font-size: 11px;
    white-space: pre-line;
    overflow-wrap: anywhere;
    text-align: left;
    color: var(--text-custom);
    line-height: 1.5;
    padding: 6px 0;
    margin-top: 2px;
    max-width: 100%;
}
.chat_message_my .chat_message_content {
    font-size: 13px;
    white-space: pre-line;
    overflow-wrap: anywhere;
    text-align: left;
    color: var(--text-custom);
    line-height: 1.5;
    padding: 1px 0;
    margin-top: 2px;
    max-width: 100%;
}
.chat_message .chat_mentions, .chat_message_my .chat_mentions {
    margin-top: 5px;
}
.chat_message a:hover, .chat_message_my a:hover {
    color: var(--span);
}
.chat_message .chat_message_date, .chat_message_my .chat_message_date {
    display: flex;
    gap: 10px;
    font-size: 8px;
    justify-content: flex-end;
    color: var(--text-custom);
}
.chat_role {
    font-size: 8px;
    background-color: var(--bg);
    border-radius: 4px;
    padding: 3px 10px;
}
.chat_nickname {
    cursor: pointer;
    font-weight: 700;
    font-size: 11px;
    color: var(--span);
    transition: .5s;
    white-space: nowrap;
    max-width: 13ch;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}
.chat_nickname:hover {
    color: var(--span);
}
.chat_message_date > stats {
    opacity: .1;
}
.chat_message_date > .mention_chat {
    color: var(--span);
    cursor: pointer;
    transition: .5s;
}
.chat_message_date > .mention_chat:hover {
    color: green;
}
.chat_meta > .del_chat_icon {
    color: var(--span);
    cursor: pointer;
    transition: .5s;
    font-size: 12px;
    font-weight: bold;
}
.chat_meta > .del_chat_icon svg { width: 1em; height: 1em; color: currentColor; fill: currentColor; stroke: currentColor; stroke-width: 0; display: inline-block; vertical-align: middle; }
.chat_meta > .del_chat_icon.ban_chat_icon svg { fill: none; stroke-width: 2.5; }
.chat_meta > .del_chat_icon:hover {
    color: red;
}
.chat_mentions > .mention_chat {
    color: var(--span);
    cursor: pointer;
    transition: .5s;
    font-size: 8px;
}
.chat_mentions > .mention_chat:hover {
    color: green;
}
#chat_profile {
    background-color: var(--bg);
    display: flex;
    padding: 10px;
    flex-direction: row;
    border-radius: 6px;
    position: relative;
}
#chat_profile > img {
    height: 30px;
    width: 30px;
    border-radius: 6px;
}
#chat_profile > .chat_profile_container {
    margin-left: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat_profile_close {
    position: absolute;
    right: 10px;
    cursor: pointer;
}
.chat_profile_container > h4 {
    margin: 0;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.block-chat-my label {
    position: absolute;
    right: 0px;
    margin-right: 15px;
}
.chat_checkbox {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}
.chat_checkbox:disabled + .toggle-track {
    cursor: not-allowed;
    opacity: 0.7;
}
.toggle-track {
    background-color: #e74c3c; /* off red by default */
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    height: 20px;
    position: relative;
    width: 40px;
    align-items: center;
}
.toggle-indicator {
    color: var(--bg);
    background-color: transparent; /* transparent knob, track shows state color */
    border-radius: 6px;
    display: flex;
    position: absolute;
    transition: 0.25s;
}
.checkMark { display: none; }
.chat_checkbox:checked + .toggle-track { background-color: #2ecc71; /* on green */ }
.chat_checkbox:checked + .toggle-track .toggle-indicator { transform: translateX(20px); }

/* Визуальный бегунок (кружок) внутри переключателя */
.toggle-indicator::after {
    content: '';
    width: 16px;
    height: 16px;
    background: var(--card);
    border-radius: 50%;
    margin-left: 2px;
}
label[for="chat_checkbox_call"] {
    display: flex;
    gap: 15px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    align-items: center;
}
.margin-30-online {
    margin-left: 5px;
    margin-top: 30px;
    margin-bottom: 30px;
}
.wbold {
    display: flex;
    background-color: var(--bg);
    height: 40px;
    border-radius: 6px;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: .5s;
    color: var(--text-custom);
}
.wbold:hover {
    color: var(--bg);
    background-color: var(--span);
}
@media (min-width: 1075px) {
    .position-block-sticky {
        height: fit-content;
        position: sticky;
        top: 75px;
    }
}
.role-chat-my {
    position: absolute;
    font-size: 8px;
    right: 5px;
    bottom: -15px;
}
.modal_okno_chat {
    position: fixed;
    transform: translate(100%, -50%);
    z-index: 9999;
    padding: 0px 15px;
    transition: .5s;
    right: 0;
    top: 50%;
    max-height: 100%;
    width: 100%;
    max-width: 500px;
}
.modal_okno_chat.show {
    transform: translate(0%, -50%);
    transition: .5s;
}
.chat_background.show {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background-color: var(--bg-modal);
    backdrop-filter: blur(5px);
    opacity: 1;
}
.chat_background {
    transition: .5s all;
    opacity: 0;
    position: fixed;
}
.block-chat-info {
    display: flex;
    height: 60px;
    gap: 15px;
    z-index: 1;
    padding: 15px;
    border-radius: 6px;
    margin-right: 15px;
    font-size: 10px;
    border: solid 2px var(--span);
    background-color: var(--bg);
    position: absolute;
    justify-content: center;
    align-items: center;
}
.block-chat-info > a {
    color: var(--span);
}
.block-chat-info > svg {
    width: 40px;
    height: 40px;
    fill: var(--span);
}
.block-chat-online {
    display: flex;
    padding: 0px 5px;
    justify-content: space-between;
    align-items: center;
}
.margin-bottom-15px {
    margin-bottom: 15px;
}
.chat_open {
    background-color: var(--span);
    color: var(--bg);
    outline: none;
    cursor: pointer;
    position: fixed;
    width: 50px;
    height: 50px;
    box-sizing: border-box;
    bottom: 15px;
    right: 15px;
    z-index: 1000;
    font-size: 20px;
    border-radius: 6px;
}
.chat_open svg {
    fill: var(--button);
    width: 20px;
    height: 20px;
}
.reload-mess {
    display: flex;
    height: 100%;
    color: green;
    align-items: center;
    justify-content: center; 
}
.chat_no_msg {
    display: flex;
    height: 100%;
    color: red;
    align-items: center;
    justify-content: center;
}
.chat_message_content emoji {
    font-size: 15px;
}

/* Force-hide info/question badge if present */
.block-chat-info { display: none !important; }

/* Remove only problematic .card styles, keep essential ones */
.card {
    /* Remove problematic styles that create extra backgrounds */
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Ensure chat block symmetry with left block */
.block-chat-back {
    margin: 0 !important;
    padding: 8px !important;
    border-radius: var(--br-16) !important;
    background-color: var(--card) !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

/* Стили для ссылок в чате */
.a-text-href {
    color: var(--span) !important;
    text-decoration: underline !important;
    cursor: pointer !important;
    transition: color 0.3s ease !important;
}

.a-text-href:hover {
    color: var(--span) !important;
    text-decoration: underline !important;
    opacity: 0.8 !important;
}

.a-text-href:visited {
    color: var(--span) !important;
}