/*
 * Mail.Ru Agent — MRIM Web Client
 * Telegram-inspired UX with Mail.Ru Agent classic brand identity
 * Flat, compact, borderless style (0px border-radius)
 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
}

body {
    font-family: tahoma, verdana, arial, sans-serif;
    font-size: 11px;
    line-height: 1.19;
    background-color: #ffffff;
    color: #1c252e;
    display: flex;
    justify-content: stretch;
    align-items: stretch;
    margin: 0 !important;
    padding: 0 !important;
}

input, button, select, textarea {
    font-family: tahoma, verdana, arial, sans-serif;
    font-size: 11px;
    line-height: 1.19;
}

/* Main Container Window */
.agent-window {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: #ffffff;
    border: 1px solid #d4d9de !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

/* Top Title Bar (Hidden per user request) */
.title-bar {
    display: none !important;
}

.title-text {
    display: none !important;
}

.ws-status-square {
    display: inline-block;
    width: 8px;
    height: 8px;
    border: 1px solid #718290;
    background-color: #ffaa00;
    flex-shrink: 0;
    margin-left: 4px;
}

/* Panels */
.panel {
    border: none;
    background-color: transparent;
    margin: 0;
    padding: 0;
}

.panel-header {
    background-color: #e8ecef;
    padding: 6px 10px;
    border-bottom: 1px solid #d0d8e0;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Login Header Bar (Compact & Expandable inside left sidebar) */
.login-panel {
    background-color: #f0f3f6;
    border-bottom: 1px solid #d0d8e0;
    padding: 8px 10px;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
}

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

.login-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.login-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: bold;
    color: #2b3a4a;
    min-width: 0;
    flex: 1;
}

.user-avatar-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #dce4eb;
    border: 1px solid #8a9aa8;
    flex-shrink: 0;
    overflow: visible;
}

.user-avatar-img-wrap {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-avatar-img.hidden,
.user-avatar-svg.hidden {
    display: none !important;
}

.user-avatar-svg {
    width: 100%;
    height: 100%;
}

.user-status-indicator {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 7px;
    height: 7px;
    border: 1px solid #ffffff;
}

.user-status-indicator.status-online { background-color: #00cc00; }
.user-status-indicator.status-away { background-color: #ffaa00; }
.user-status-indicator.status-offline { background-color: #aaaaaa; }

.user-email-preview {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    color: #2b3a4a;
    font-size: 11px;
}

.user-email-preview.authenticated {
    color: #1b5e20;
    font-weight: 500;
}

.user-email-preview.error {
    color: #cc0000;
    font-weight: bold;
}

.user-email-accent {
    color: #006600;
    font-weight: bold;
}

.login-header-actions {
    display: flex;
    align-items: center;
    width: 100%;
}

.panel-buttons-group {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.panel-buttons-group .btn {
    flex: 1;
    text-align: center;
    padding: 3px 4px;
    font-size: 11px;
}

/* Common Buttons */
.btn {
    padding: 3px 8px;
    background-color: #d0d8e0;
    border: 1px solid #7a8a9a;
    cursor: pointer;
    font-family: Tahoma, Verdana, sans-serif;
    font-size: 11px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    background-color: #c0c8d0;
}

.btn:disabled {
    background-color: #e0e0e0;
    color: #888888;
    border-color: #cccccc;
    cursor: default;
}

.btn-small {
    padding: 2px 6px;
    font-size: 11px;
}

.btn-login {
    font-weight: bold;
    background-color: #3b5998;
    color: #ffffff;
    border-color: #294273;
}

.btn-login:hover {
    background-color: #2e4678;
}

.btn-toggle {
    padding: 2px 6px;
    background-color: #d0d8e0;
    border: 1px solid #7a8a9a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
}

.btn-toggle:hover {
    background-color: #bcd0e0;
}

.toggle-chevron {
    display: inline-block;
    font-size: 9px;
    transition: transform 0.25s ease;
    color: #334455;
}

/* Expandable Login Content */
.login-expandable-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, margin-top 0.2s ease;
}

.login-panel.expanded .login-expandable-content {
    max-height: 280px;
    opacity: 1;
    margin-top: 6px;
}

.login-panel.expanded .toggle-chevron {
    transform: rotate(180deg);
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background-color: #ffffff;
    border: 1px solid #c0c8d0;
    margin-top: 4px;
}

.form-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    width: 100%;
}

.form-field label {
    font-size: 10px;
    font-weight: bold;
    color: #334455;
    white-space: nowrap;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field select {
    flex: 1;
    width: 100%;
    padding: 3px 6px;
    border: 1px solid #7a8a9a;
    background-color: #ffffff;
    font-family: Tahoma, Verdana, sans-serif;
    font-size: 11px;
    outline: none;
}

.form-field input[type="text"]:focus,
.form-field input[type="password"]:focus,
.form-field select:focus {
    border-color: #3b5998;
}

.auth-status-bar {
    margin-top: 4px;
    padding: 3px 6px;
    background-color: #fcfcfc;
    border: 1px solid #c0c8d0;
    font-size: 11px;
}

/* Workspace Layout: Fullscreen Single View (Contacts View or Chat View) */
.workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    background-color: #ffffff;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* 1) Contacts Page View (default) */
.workspace.mobile-view-contacts .contacts-panel,
.workspace:not(.mobile-view-chat) .contacts-panel {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    border-right: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.workspace.mobile-view-contacts .chat-panel,
.workspace:not(.mobile-view-chat) .chat-panel {
    display: none !important;
}

/* 2) Chat Page View (when contact is opened) */
.workspace.mobile-view-chat .contacts-panel {
    display: none !important;
}

.workspace.mobile-view-chat .chat-panel {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Contacts Panel Header */
.contacts-panel .panel-header {
    background-color: #e8ecef;
    padding: 8px 12px;
    border-bottom: 1px solid #d0d8e0;
    margin: 0;
    font-weight: bold;
    color: #2b3a4a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    font-size: 13px;
}

/* Contacts List (Scrollable Middle Area) */
.contacts-list {
    flex: 1;
    overflow-y: auto;
    border: none;
    background-color: #ffffff;
    padding: 0;
    margin: 0;
}

.contact-item {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f3f6;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.contact-avatar-badge,
.contact-name-group,
.contact-name,
.contact-last-date,
.contact-subtext {
    cursor: pointer;
}

.contact-name:hover {
    text-decoration: underline;
    color: #1a3e5e;
}

.contact-item.contact-search-action {
    background-color: #f3f7fa;
    border-bottom: 1px solid #dce4ec;
    border-left: 3px solid #2b5d84;
}

.contact-item.contact-search-action:hover {
    background-color: #e6eef5;
}

.search-action-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2b5d84;
    color: #ffffff;
    font-size: 18px;
    border-radius: 2px;
}

.contact-name-group {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    gap: 2px;
}

.contact-openvk-link {
    font-size: 11px;
    color: #2b587a;
    text-decoration: none;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    cursor: pointer;
}

.contact-openvk-link:hover {
    text-decoration: underline;
    color: #1e3d55;
}

.vk-profile-ovk-link {
    font-size: 11px;
    color: #2b587a;
    text-decoration: none;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.2;
    margin-top: 2px;
    margin-bottom: 2px;
    display: inline-block;
    cursor: pointer;
}

.vk-profile-ovk-link:hover {
    text-decoration: underline;
    color: #1e3d55;
}

.contact-last-date {
    font-size: 11px;
    color: #777777;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-subtext {
    font-size: 11px;
    color: #777777;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
}

.contact-item.active {
    background-color: #e1ebf5;
    border-left: 3px solid #2b5d84;
}

.contact-left {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.contact-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 6px;
}

.contact-avatar-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    min-width: 48px;
    background-color: #dce4eb;
    object-fit: cover;
    border: none;
    border-radius: 2px;
    flex-shrink: 0;
}

.active-chat-avatar {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: none;
}

.msg-avatar {
    width: 18px;
    height: 18px;
    min-width: 18px;
    object-fit: cover;
    border: none;
    vertical-align: middle;
    margin-right: 4px;
    display: inline-block;
}

.contact-status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    display: inline-block;
    border: 1px solid #ffffff;
    box-shadow: 0 0 2px rgba(0,0,0,0.25);
    flex-shrink: 0;
}

.status-online { background-color: #00cc00; }
.status-away { background-color: #ffaa00; }
.status-offline { background-color: #aaaaaa; }

.contact-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    font-weight: bold;
    color: #2b587a;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
}

.unread-badge {
    background-color: #3b5998;
    color: #ffffff;
    font-size: 10px;
    padding: 1px 5px;
    font-weight: bold;
}

.empty-list {
    color: #778899;
    text-align: center;
    padding: 24px 12px;
    font-size: 11px;
}

/* Quick Add Contact at Bottom of Left Sidebar */
.direct-msg-box {
    padding: 8px 10px 14px 10px;
    background-color: #f0f4f8;
    border-top: 1px solid #d0d8e0;
    margin: 0;
    flex-shrink: 0;
}

.direct-msg-box label {
    font-size: 10px;
    font-weight: bold;
    color: #4a5a6a;
    margin-bottom: 6px;
    display: block;
}

.direct-input-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.direct-input-row input {
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
    border: 1px solid #7a8a9a;
    font-size: 11px;
    background-color: #ffffff;
    outline: none;
}

.direct-input-row input:focus {
    border-color: #3b5998;
}

.direct-input-row .btn {
    padding: 3px 8px;
    height: 23px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.btn-chat {
    background-color: #3b5998;
    color: #ffffff;
    border: 1px solid #294273;
    font-weight: bold;
}

.btn-chat:hover {
    background-color: #2e4678;
}

/* Right Column: Chat Panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    margin: 0;
    padding: 0;
    border: none;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.chat-panel .panel-header.chat-header-row {
    display: none !important;
}

.chat-title-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    min-width: 0;
    font-size: 12px;
}

.chat-history {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    border: none;
    background-color: #ffffff;
    padding: 14px 64px 20px 64px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

@media (max-width: 960px) {
    .chat-history {
        padding: 14px 0px 20px 64px;
    }
}

@media (max-width: 600px) {
    .chat-history {
        padding: 12px 14px 16px 14px;
    }
}

.chat-welcome {
    color: #445566;
    line-height: 1.5;
    background-color: #ffffff;
    border: 1px solid #d8e0e8;
    padding: 12px;
    max-width: 480px;
    margin: 16px auto;
    font-size: 12px;
}

/* Messages (VK style layout matching reference) */
.message-item {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: flex-start;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box;
}

.msg-content-wrap {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: calc(100% - 125px);
    min-width: 0;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    max-width: 36px;
    border-radius: 2px !important;
    object-fit: cover;
    background-color: #adb8c5;
    border: none !important;
    flex-shrink: 0;
    display: block;
    margin: 0 !important;
}

.msg-body-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding-top: 1px;
}

.msg-author {
    font-weight: bold;
    color: #2b587a;
    font-size: 12.5px;
    font-family: Tahoma, Arial, "Segoe UI", sans-serif;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

a.msg-author,
.msg-author.ovk-link {
    cursor: pointer;
    color: #2b587a;
}

a.msg-author:hover,
.msg-author.ovk-link:hover {
    text-decoration: underline;
    color: #1e3e5c;
}

div.msg-author:not(.ovk-link) {
    cursor: default;
}

.msg-author.me {
    color: #2b587a;
}

.msg-text {
    font-size: 13px;
    color: #000000;
    font-family: Tahoma, Arial, "Segoe UI", sans-serif;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
    text-align: left;
}

.msg-date-col {
    font-size: 11px;
    font-family: Tahoma, Arial, "Segoe UI", sans-serif;
    color: #828a99;
    white-space: nowrap;
    padding-top: 2px;
    margin-left: 14px;
    text-align: right;
    flex-shrink: 0;
    user-select: none;
}

.mrim-smile {
    vertical-align: -3px;
    margin: 0 1px;
    max-height: 22px;
    max-width: 28px;
    object-fit: contain;
    display: inline-block;
}

/* Bottom Message Send Form */
.send-box {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    background-color: #eceff2;
    border-top: 1px solid #d4d9de;
    flex-shrink: 0;
}

/* Smile Picker Popup (Dark translucent compact popup matching reference) */
.smile-picker-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    right: var(--popup-right, 68px);
    left: var(--popup-left, auto);
    width: 260px;
    max-width: calc(100% - 16px);
    background-color: rgba(30, 34, 40, 0.86) !important;
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
    border-radius: 7px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: visible; /* To allow arrow to show */
    animation: smile-popup-appear 0.15s ease-out;
}

@keyframes smile-popup-appear {
    from {
        opacity: 0;
        transform: translateY(4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Downward arrow pointing directly to the smile trigger */
.smile-picker-arrow {
    position: absolute;
    bottom: -6px;
    right: var(--arrow-right, 24px);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(30, 34, 40, 0.86);
    pointer-events: none;
    transform: translateX(50%);
}

.smile-picker-popup::after {
    display: none !important;
}

.smile-picker-popup.hidden {
    display: none !important;
}

.smile-picker-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
}

.smile-picker-grid,
.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 27px);
    justify-content: center;
    gap: 3px;
    padding: 6px;
    max-height: 132px;
    overflow-y: auto;
    background-color: transparent;
    box-sizing: border-box;
}

.smile-picker-grid.hidden,
.emoji-picker-grid.hidden {
    display: none !important;
}

.smile-picker-item,
.emoji-picker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 27px;
    width: 27px;
    background-color: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.12s ease, transform 0.1s ease;
    box-sizing: border-box;
    font-size: 15px;
    line-height: 1;
}

.smile-picker-item:hover,
.emoji-picker-item:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.15);
    z-index: 2;
}

.smile-picker-item img {
    max-width: 20px;
    max-height: 20px;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

/* Kaomoji Picker Grid */
.kaomoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 6px;
    max-height: 132px;
    overflow-y: auto;
    background-color: transparent;
    box-sizing: border-box;
}

.kaomoji-picker-grid.hidden {
    display: none !important;
}

.kaomoji-picker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 5px;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    cursor: pointer;
    font-size: 10.5px;
    font-family: inherit;
    color: #e2e8f0;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.kaomoji-picker-item:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Smile Picker Footer & Tabs (Single unified background) */
.smile-picker-footer {
    background-color: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.smile-picker-tabs {
    display: flex;
    gap: 2px;
}

.smile-picker-tab {
    padding: 2px 6px;
    font-size: 10.5px;
    font-weight: 500;
    color: #94a3b8;
    background-color: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.12s ease, color 0.12s ease;
    font-family: Tahoma, Arial, sans-serif;
}

.smile-picker-tab:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

.smile-picker-tab.active {
    background-color: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    font-weight: bold;
}

.smile-picker-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: color 0.12s, background-color 0.12s;
}

.smile-picker-close-btn:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.15);
}

/* Dark Custom Scrollbar inside Picker */
.smile-picker-grid::-webkit-scrollbar,
.emoji-picker-grid::-webkit-scrollbar,
.kaomoji-picker-grid::-webkit-scrollbar {
    width: 4px;
}

.smile-picker-grid::-webkit-scrollbar-track,
.emoji-picker-grid::-webkit-scrollbar-track,
.kaomoji-picker-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.smile-picker-grid::-webkit-scrollbar-thumb,
.emoji-picker-grid::-webkit-scrollbar-thumb,
.kaomoji-picker-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 2px;
}

.send-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    width: 100%;
}

.send-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
}

#btn-sound-toggle {
    margin-left: auto;
}

.btn-toolbar-stub {
    font-size: 11px;
    padding: 2px 8px;
    background-color: #f0f3f6;
    border: 1px solid #c0c8d0;
    color: #4a5a6a;
    cursor: pointer;
    border-radius: 2px;
}

.btn-toolbar-stub:hover {
    background-color: #e1ebf5;
    border-color: #7a8a9a;
    color: #1c252e;
}

.send-box textarea,
.send-box .message-input {
    flex: 1;
    min-height: 32px;
    height: 32px;
    max-height: 96px;
    padding: 6px 10px;
    border: 1px solid #b0bec5;
    font-family: inherit;
    font-size: 12px;
    line-height: 18px;
    resize: none;
    outline: none;
    background-color: #f8fafc;
    box-sizing: border-box;
    transition: border-color 0.15s, background-color 0.15s;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.send-box textarea:focus,
.send-box .message-input:focus {
    border-color: #3b5998;
    background-color: #ffffff;
}

.send-box .message-input[contenteditable="false"] {
    background-color: #f0f0f0;
    color: #888888;
    cursor: not-allowed;
}

.send-box .message-input:empty::before {
    content: attr(placeholder);
    color: #8f9bb3;
    pointer-events: none;
    display: block;
}

.mrim-smile-input {
    width: 18px;
    height: 18px;
    vertical-align: -3px;
    display: inline-block;
    margin: 0 1px;
    user-select: none;
    pointer-events: none;
}

.send-buttons {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.btn-send {
    height: 32px;
    padding: 0 16px;
    font-weight: bold;
    background-color: #3b5998;
    color: #ffffff;
    border: 1px solid #294273;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    white-space: nowrap;
    transition: background-color 0.15s;
}

.btn-send:hover {
    background-color: #2e4678;
}

.btn-send:disabled {
    background-color: #c0c8d0;
    color: #ffffff;
    border-color: #a0a8b0;
    cursor: not-allowed;
}

/* Bottom Collapsible Logs Panel */
.logs-panel {
    background-color: #ffffff;
    border-top: 1px solid #d0d8e0;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

.logs-panel .panel-header {
    background-color: #e8ecef;
    padding: 4px 10px;
    border-bottom: 1px solid #d0d8e0;
    margin: 0;
    font-size: 11px;
    cursor: pointer;
    user-select: none;
}

.logs-header-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logs-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.logs-expandable-content {
    max-height: 120px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.logs-panel.collapsed .logs-expandable-content {
    max-height: 0;
    opacity: 0;
}

.logs-panel.collapsed #logs-toggle-chevron {
    transform: rotate(180deg);
}

.logs-panel.collapsed .panel-header {
    border-bottom: none;
}

.logs-console {
    height: 110px;
    overflow-y: auto;
    background-color: #0d1117;
    color: #c9d1d9;
    font-family: monospace;
    font-size: 11px;
    padding: 4px 8px;
    line-height: 1.35;
    border: none;
}

.log-line {
    margin-bottom: 2px;
}

.log-info { color: #58a6ff; }
.log-error { color: #f85149; font-weight: bold; }
.log-warning { color: #d29922; }
.log-debug { color: #8b949e; }

.btn-auth {
    background-color: #f0f3f6;
    color: #4a5a6a;
    border: 1px solid #c0c8d0;
    font-weight: normal;
}

.btn-auth:hover {
    background-color: #e1ebf5;
    border-color: #7a8a9a;
    color: #1c252e;
}

.msg-auth-card {
    background-color: #e6f4ea;
    border: 1px solid #34a853;
    padding: 6px 10px;
    margin-top: 4px;
    margin-bottom: 4px;
}

.auth-card-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}

.auth-card-title {
    color: #137333;
    font-size: 11px;
}

.btn-approve-card {
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.typing-status {
    font-size: 11px;
    color: #0078d4;
    font-style: italic;
    margin-left: 6px;
}

.hidden {
    display: none !important;
}

/* Modal Overlay & Base Window Styles (VK Style Matching Reference) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 16px;
    box-sizing: border-box;
}.modal-window,
.vk-modal-window {
    background-color: #ffffff !important;
    border: 1px solid #4a6f94 !important;
    border-radius: 2px !important;
    box-shadow: 0 4px 22px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08) !important;
    width: 100% !important;
    max-width: 490px !important;
    max-height: 88vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    z-index: 10001 !important;
    font-family: tahoma, verdana, arial, sans-serif !important;
    box-sizing: border-box !important;
}

.modal-header,
.vk-modal-header {
    background: #597da3 !important;
    background-color: #597da3 !important;
    color: #ffffff !important;
    padding: 0 14px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-weight: bold !important;
    font-size: 12px !important;
    border-bottom: none !important;
    flex-shrink: 0 !important;
    height: 34px !important;
    box-sizing: border-box !important;
}

.modal-title,
.vk-modal-title {
    font-size: 12px !important;
    font-weight: bold !important;
    color: #ffffff !important;
    font-family: tahoma, verdana, arial, sans-serif !important;
    letter-spacing: normal !important;
    line-height: 1.19 !important;
}

.modal-close-link {
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-family: tahoma, verdana, arial, sans-serif !important;
    font-weight: normal !important;
    cursor: pointer !important;
    padding: 2px 4px !important;
    margin: 0 !important;
    border-radius: 2px !important;
    opacity: 0.9 !important;
    text-decoration: none !important;
    outline: none !important;
    line-height: 1.19 !important;
}

.modal-close-link:hover {
    opacity: 1 !important;
    text-decoration: underline !important;
    color: #ffffff !important;
    background: transparent !important;
}

.modal-close-btn {
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-family: tahoma, verdana, arial, sans-serif !important;
    font-weight: normal !important;
    cursor: pointer !important;
    padding: 0 !important;
    text-decoration: none !important;
}

.modal-close-btn:hover {
    text-decoration: underline !important;
}

.modal-body,
.vk-modal-body {
    padding: 14px 16px !important;
    overflow-y: auto !important;
    flex: 1 1 auto !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
    color: #222222 !important;
    background-color: #ffffff !important;
    font-family: tahoma, verdana, arial, sans-serif !important;
    box-sizing: border-box !important;
}

.modal-footer,
.vk-modal-footer {
    padding: 8px 14px !important;
    background-color: #f0f2f5 !important;
    border-top: 1px solid #dae1e8 !important;
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
}

/* VK Button Styles Matching Screenshot */
.vk-btn-primary {
    background-color: #5f7e9d !important;
    border: 1px solid #4a6787 !important;
    color: #ffffff !important;
    font-family: tahoma, verdana, arial, sans-serif !important;
    font-size: 11px !important;
    font-weight: normal !important;
    padding: 4px 16px !important;
    border-radius: 2px !important;
    cursor: pointer !important;
    text-align: center !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1.19 !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    outline: none !important;
    box-sizing: border-box !important;
}

.vk-btn-primary:hover:not(:disabled) {
    background-color: #527094 !important;
    border-color: #3f5c7c !important;
}

.vk-btn-primary:active:not(:disabled) {
    background-color: #466282 !important;
    border-color: #385370 !important;
}

.vk-btn-primary:disabled {
    background-color: #9bb1c6 !important;
    border-color: #8fa5ba !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
    box-shadow: none !important;
}

.vk-btn-secondary {
    background-color: #e5ebf1 !important;
    border: 1px solid #c5d0db !important;
    color: #556b82 !important;
    font-family: tahoma, verdana, arial, sans-serif !important;
    font-size: 11px !important;
    font-weight: normal !important;
    padding: 4px 14px !important;
    border-radius: 2px !important;
    cursor: pointer !important;
    text-align: center !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1.19 !important;
    outline: none !important;
    box-sizing: border-box !important;
}

.vk-btn-secondary:hover:not(:disabled) {
    background-color: #dce4ec !important;
    color: #364d63 !important;
    border-color: #b5c2cf !important;
}

.vk-btn-secondary:active:not(:disabled) {
    background-color: #cfd9e3 !important;
    color: #273849 !important;
}

/* VK Tabs in Modal */
.vk-modal-tabs {
    display: flex;
    background-color: #edeef0;
    border-bottom: 1px solid #d3d9de;
    padding: 0 14px;
    gap: 4px;
    flex-shrink: 0;
}

.vk-modal-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #656565;
    font-family: tahoma, verdana, arial, sans-serif;
    font-size: 11px;
    font-weight: normal;
    padding: 8px 10px 6px 10px;
    cursor: pointer;
    outline: none;
    user-select: none;
    border-radius: 0;
    margin-bottom: -1px;
    line-height: 1.19;
    transition: color 0.12s ease;
}

.vk-modal-tab-btn:hover {
    color: #2a5885;
}

.vk-modal-tab-btn.active {
    color: #2a5885;
    font-weight: bold;
    border-bottom: 2px solid #5181b8;
    background: transparent;
}

.vk-tab-pane {
    display: block;
}

.vk-tab-pane.hidden {
    display: none !important;
}

/* User Account Profile Banner (VK Style) */
.vk-profile-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f7f9fb;
    border: 1px solid #dce4eb;
    border-radius: 2px;
    margin-bottom: 14px;
}

.vk-avatar-container {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.vk-avatar-wrap {
    width: 48px;
    height: 48px;
    border-radius: 2px;
    overflow: hidden;
    background-color: #e2e8f0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vk-avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vk-avatar-wrap svg {
    width: 26px;
    height: 26px;
}

.vk-profile-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.vk-profile-name {
    font-size: 12px;
    font-weight: bold;
    color: #2a5885;
    font-family: Tahoma, Arial, sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vk-profile-name.authenticated {
    color: #224b7a;
}

.vk-profile-status-line {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #656565;
}

.vk-status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #00cc00;
    flex-shrink: 0;
}

.vk-profile-status-desc {
    color: #656565;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* VK Form 2-Column Table Grid */
.vk-form-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vk-form-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vk-form-label {
    width: 120px;
    text-align: right;
    font-size: 12px;
    color: #656565;
    font-family: Tahoma, Arial, sans-serif;
    flex-shrink: 0;
    line-height: 1.3;
}

.vk-form-control {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vk-form-hint {
    font-size: 11px;
    color: #828282;
    line-height: 1.35;
    margin-top: 2px;
}

.vk-btn-group {
    display: flex;
    flex-direction: row;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.vk-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #222222;
    user-select: none;
    font-family: Tahoma, Arial, sans-serif;
}

.vk-checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #5181b8;
}

.vk-input,
.vk-select {
    width: 100%;
    height: 28px;
    padding: 3px 7px;
    border: 1px solid #d3d9de;
    border-radius: 0;
    font-size: 12px;
    font-family: Tahoma, Arial, sans-serif;
    background-color: #ffffff;
    color: #000000;
    outline: none;
    box-sizing: border-box;
}

.vk-input:focus,
.vk-select:focus {
    border-color: #5181b8;
}

.vk-input::placeholder {
    color: #999999;
}

.vk-input-file {
    font-size: 11px;
    font-family: Tahoma, Arial, sans-serif;
    color: #333333;
    padding: 2px 0;
}

/* VK PWA Cards */
.vk-pwa-banner {
    background: #eef4f9;
    border: 1px solid #c5d8e8;
    border-radius: 0;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vk-pwa-banner-text {
    font-size: 12px;
    color: #2a5885;
    font-weight: bold;
}

.vk-pwa-card {
    background: #f7f9fb;
    border: 1px solid #dce4eb;
    border-radius: 0;
    padding: 10px 12px;
}

.vk-pwa-card-header {
    font-size: 12px;
    font-weight: bold;
    color: #2a5885;
    margin-bottom: 4px;
    font-family: Tahoma, Arial, sans-serif;
}

.vk-pwa-card-body {
    font-size: 11.5px;
    color: #444444;
    line-height: 1.45;
    font-family: Tahoma, Arial, sans-serif;
}

.vk-pwa-status-box {
    margin-top: 10px;
    padding: 8px 10px;
    background-color: #f7f9fb;
    border-left: 3px solid #5181b8;
    border-radius: 0;
    font-size: 11px;
    color: #556677;
    font-family: Tahoma, Arial, sans-serif;
}

/* VK About Pane Styles */
.vk-about-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: Tahoma, Verdana, Arial, sans-serif;
}

.vk-about-header-card {
    background: #f7f9fb;
    border: 1px solid #dce4eb;
    padding: 10px 12px;
    border-radius: 2px;
}

.vk-about-app-title {
    font-size: 13px;
    font-weight: bold;
    color: #2a5885;
    margin-bottom: 3px;
}

.vk-about-app-desc {
    font-size: 11.5px;
    color: #555555;
    line-height: 1.4;
}

.vk-about-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 10px 12px;
    border-radius: 2px;
}

.vk-about-section-title {
    font-size: 11.5px;
    font-weight: bold;
    color: #2a5885;
    margin-bottom: 8px;
    border-bottom: 1px solid #edf2f7;
    padding-bottom: 4px;
}

.vk-about-fork-info {
    font-size: 11.5px;
    color: #444444;
    margin-bottom: 8px;
    line-height: 1.35;
}

.vk-about-links-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vk-about-link-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    background: #f7f9fb;
    border: 1px solid #e7ecf1;
    border-radius: 2px;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.vk-about-link-item:hover {
    background-color: #eef4f9;
    border-color: #c5d8e8;
}

.vk-about-link-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.vk-about-link-label {
    font-size: 11px;
    color: #667788;
    min-width: 75px;
    flex-shrink: 0;
}

.vk-about-link-value {
    font-size: 11.5px;
    color: #2a5885;
    font-weight: normal;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vk-about-link-item:hover .vk-about-link-value {
    text-decoration: underline;
    color: #1a3e5e;
}

@media (max-width: 480px) {
    .vk-form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .vk-form-label {
        width: 100%;
        text-align: left;
    }
}

.mrim-smile {
    max-width: 22px;
    max-height: 22px;
    width: auto;
    height: auto;
    display: inline-block;
    vertical-align: middle;
    margin: 0 2px;
}

.mobile-workspace-tabs {
    display: none !important;
}

.btn-back-contacts {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px;
    padding: 5px 12px !important;
    font-size: 12px !important;
    font-weight: bold !important;
    color: #ffffff !important;
    background-color: #3b5998 !important;
    border: 1px solid #294273 !important;
    border-radius: 3px !important;
    cursor: pointer !important;
    margin-right: 8px !important;
    flex-shrink: 0 !important;
}

.btn-back-contacts:hover {
    background-color: #4c70ba !important;
}

.btn-back-contacts:active {
    background-color: #294273 !important;
}

/* Chat Header Row */
.chat-panel .panel-header.chat-header-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 6px 12px;
    background-color: #ffffff;
    border-bottom: 1px solid #d0d8e0;
    flex-shrink: 0;
}

.chat-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: 0;
    font-size: 13px;
    flex: 1;
}

.chat-title-group .active-chat-avatar {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 2px;
}

.chat-title-prefix {
    color: #4a5a6a;
    font-weight: bold;
}

#current-chat-title {
    font-weight: bold;
    color: #1a2a3a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.typing-status {
    font-size: 11px;
    color: #2563eb;
    font-style: italic;
    white-space: nowrap;
}

#chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Mobile & Tablet Styles */
@media (max-width: 768px) {
    html, body {
        padding: 0;
        margin: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .agent-window {
        border: none;
        box-shadow: none;
        max-width: 100%;
        width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
}

    .contacts-panel {
        width: 100%;
        max-width: 100%;
        flex: 1;
        min-height: 0;
    }

    .contacts-list {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .contact-item {
        padding: 10px 12px;
        min-height: 48px;
    }

    html body .contact-item.active {
        background: transparent !important;
        background-color: transparent !important;
        border-left: none !important;
        border-top: none !important;
        outline: none !important;
        box-shadow: none !important;
        font-weight: normal !important;
    }

    html body .contact-item.active .contact-name {
        color: inherit !important;
        text-shadow: none !important;
    }

    .contact-name {
        font-size: 13px;
    }

    .logs-panel {
        display: none !important;
    }

    .chat-history {
        flex: 1 1 0%;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        padding: 10px;
    }

    .message-item {
        max-width: 90%;
    }

    .send-box {
        padding: 8px 10px;
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        z-index: 15;
        background-color: #ffffff;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    }

    .send-box textarea,
    .send-box .message-input {
        min-height: 38px;
        font-size: 16px;
        padding: 8px 10px;
    }

    .btn-send {
        height: 38px;
        padding: 0 16px;
        font-size: 13px;
    }

    .send-toolbar {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }

    .btn-toolbar-stub {
        padding: 6px 12px;
        font-size: 12px;
    }

    .smile-picker-popup {
        right: var(--popup-right, 12px);
        left: var(--popup-left, auto);
        width: 260px;
        max-width: calc(100vw - 24px);
        bottom: calc(100% + 6px);
        max-height: 48vh;
    }

    /* Remove custom theme scrollbars on mobile devices */
    ::-webkit-scrollbar,
    *::-webkit-scrollbar,
    *::-webkit-scrollbar-track,
    *::-webkit-scrollbar-thumb,
    *::-webkit-scrollbar-button,
    *::-webkit-scrollbar-corner {
        width: 0 !important;
        height: 0 !important;
        display: none !important;
        background: transparent !important;
        border: none !important;
    }

    * {
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }
}

/* WakeUp Message Shake Animation */
@keyframes wakeup-shake {
    0% { transform: translate(0, 0) rotate(0deg); }
    15% { transform: translate(-5px, 4px) rotate(-1.5deg); }
    30% { transform: translate(5px, -4px) rotate(1.5deg); }
    45% { transform: translate(-4px, -3px) rotate(-1deg); }
    60% { transform: translate(4px, 3px) rotate(1deg); }
    75% { transform: translate(-2px, 2px) rotate(-0.5deg); }
    90% { transform: translate(2px, -1px) rotate(0.5deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.shake-effect {
    animation: wakeup-shake 0.25s ease-in-out 3;
}

.message-item.wakeup-message {
    /* Retains standard message appearance */
}

/* ========================================================= */
/* ENFORCE 3 FULL-SCREEN PAGES: CONTACTS / CHAT / SEARCH     */
/* ========================================================= */

.workspace {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    position: relative !important;
}

/* 1. CONTACTS VIEW (Default) */
.workspace:not(.mobile-view-chat):not(.view-search) .contacts-panel,
.workspace.mobile-view-contacts .contacts-panel {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    flex: 1 1 100% !important;
    border-right: none !important;
}

.workspace:not(.mobile-view-chat):not(.view-search) .chat-panel,
.workspace:not(.mobile-view-chat):not(.view-search) .search-panel,
.workspace.mobile-view-contacts .chat-panel,
.workspace.mobile-view-contacts .search-panel {
    display: none !important;
}

/* 2. CHAT VIEW */
.workspace.mobile-view-chat .contacts-panel,
.workspace.mobile-view-chat .search-panel {
    display: none !important;
}

.workspace.mobile-view-chat .chat-panel {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    flex: 1 1 100% !important;
}

/* 3. SEARCH VIEW */
.workspace.view-search .contacts-panel,
.workspace.view-search .chat-panel {
    display: none !important;
}

.workspace.view-search .search-panel {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    flex: 1 1 100% !important;
    background-color: #ffffff !important;
}

/* Search panel internal layout */
.search-panel-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.direct-msg-box-search {
    background: #f8fafc;
    border: 1px solid #dce1e6;
    border-radius: 6px;
    padding: 16px;
    max-width: 600px;
    width: 100%;
}

/* ========================================================= */
/* PIXEL-PERFECT TOP BAR & COMPOSE HEADER (Mail.Ru Style)    */
/* ========================================================= */

.mailru-contacts-header {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #ffffff;
    flex-shrink: 0;
}

.mailru-tab-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 7px 10px 0 8px;
    background: #ffffff;
    border-bottom: 1px solid #36638e;
    box-sizing: border-box;
    gap: 10px;
}

.mailru-tabs-group {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.mailru-tab-dialogs,
.mailru-tab-view-dialog {
    background: transparent;
    color: #2b587a;
    border: none;
    font-family: tahoma, verdana, arial, sans-serif;
    font-size: 11px;
    font-weight: normal;
    padding: 3px 6px 4px 6px;
    border-radius: 2px 2px 0 0;
    user-select: none;
    line-height: 1.19;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    text-decoration: none;
    outline: none;
    transition: color 0.1s ease;
}

.mailru-tab-dialogs:hover,
.mailru-tab-view-dialog:hover {
    background: transparent;
    color: #2b587a;
    text-decoration: underline;
}

.mailru-tab-dialogs.active,
.mailru-tab-view-dialog.active {
    background-color: #36638e !important;
    color: #ffffff !important;
    border: none !important;
    font-weight: normal !important;
    cursor: default;
    text-decoration: none !important;
    padding: 3px 8px 4px 8px;
    border-radius: 2px 2px 0 0;
}

.mailru-tab-view-dialog.hidden {
    display: none !important;
}

.mailru-chat-top-header {
    border-bottom: none;
}

.mailru-tab-settings-link {
    background: transparent;
    border: none;
    color: #2b587a;
    font-size: 11px;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
    cursor: pointer;
    padding: 0 2px 4px 0;
    text-decoration: none;
    outline: none;
}

.mailru-tab-settings-link:hover {
    text-decoration: underline;
    color: #2b587a;
}

.mailru-compose-bar {
    display: flex;
    align-items: center;
    padding: 6px 14px;
    background-color: #eceff2;
    border-bottom: 1px solid #d4d9de;
    gap: 6px;
    box-sizing: border-box;
    margin: 0;
    width: 100%;
}

.mailru-compose-input {
    flex: 1;
    min-width: 0;
    height: 23px;
    background-color: #ffffff;
    border: 1px solid #c0cad5;
    border-radius: 1px;
    padding: 0 6px;
    font-size: 11px;
    color: #222222;
    outline: none;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
    box-sizing: border-box;
}

.mailru-compose-input::placeholder {
    color: #777777;
}

.mailru-compose-input:focus {
    border-color: #2b587a;
}

.mailru-compose-btn {
    height: 23px;
    background-color: #2b587a;
    color: #ffffff;
    border: 1px solid #204664;
    border-radius: 2px;
    padding: 0 10px;
    font-size: 11px;
    font-weight: normal;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
    box-sizing: border-box;
    flex-shrink: 0;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.mailru-compose-btn:hover {
    background-color: #356e9c;
}

.mailru-compose-btn:active {
    background-color: #1e4564;
}

.mailru-compose-btn-settings {
    background-color: #2b587a;
    padding: 0 8px;
}

.mailru-compose-btn-dialogs {
    background: transparent;
    border: none;
    color: #2b587a;
    font-size: 11px;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
    padding: 0 4px;
    margin: 0;
    border-radius: 0;
    cursor: pointer;
    text-decoration: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    user-select: none;
    transition: color 0.1s ease;
}

.mailru-compose-btn-dialogs:hover {
    background: transparent;
    color: #1a3e5e;
    text-decoration: underline;
}

.mailru-compose-btn-dialogs:active {
    background: transparent;
    color: #0e2a42;
}

.mailru-chat-top-spacer {
    flex: 1;
}

.mailru-chat-top-peer {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    padding: 0 8px;
}

.chat-top-peer-name {
    font-size: 11px;
    font-family: tahoma, verdana, arial, sans-serif;
    color: #2b587a;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    display: inline-block;
    max-width: 100%;
}

a.chat-top-peer-name {
    cursor: pointer;
}

a.chat-top-peer-name:hover {
    text-decoration: underline;
    color: #1e4564;
}

/* ========================================================= */
/* MAIL.RU CHAT SEND FORM WITH SIDE AVATARS (REFERENCE MATCH)*/
/* ========================================================= */

.mailru-chat-send-box {
    padding: 8px 14px 8px 14px !important;
    background-color: #eceff2 !important;
    border-top: 1px solid #d4d9de !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    position: relative;
    box-sizing: border-box;
}

.mailru-send-main-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
}

.mailru-chat-avatar-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex-shrink: 0;
    width: 50px;
    padding-top: 1px;
}

.mailru-send-center-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mailru-side-avatar-img {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    border: 1px solid #d4d9de;
}

.mailru-peer-status-text {
    font-size: 11px;
    color: #7b8a99;
    font-family: Tahoma, Arial, sans-serif;
    margin-top: 2px;
    line-height: 1;
    text-align: center;
}

.mailru-input-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #d4d9de;
    border-radius: 2px;
    padding: 2px 8px;
    min-height: 40px;
    box-sizing: border-box;
    position: relative;
    transition: border-color 0.15s;
}

.mailru-input-wrapper:focus-within {
    border-color: #2b5d84;
}

.mailru-message-input,
.mailru-message-input *,
#message-input,
#message-input *,
.message-input,
.message-input * {
    font-size: 11px !important;
    font-family: tahoma, verdana, arial, sans-serif !important;
    line-height: 1.35 !important;
    color: #222222;
}

.mailru-message-input {
    flex: 1;
    min-height: 32px;
    max-height: 90px;
    border: none !important;
    background: transparent !important;
    padding: 4px 2px 4px 0 !important;
    outline: none !important;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.mailru-message-input:empty::before,
#message-input:empty::before {
    content: attr(placeholder);
    color: #8c9ba9;
    font-family: tahoma, verdana, arial, sans-serif !important;
    font-size: 11px !important;
    line-height: inherit;
    pointer-events: none;
    display: block;
}

.mailru-input-embed-icons {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding-left: 6px;
    flex-shrink: 0;
}

.mailru-embed-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    opacity: 0.85;
    transition: opacity 0.15s;
}

.mailru-embed-icon-btn:hover {
    opacity: 1;
}

.mailru-embed-icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Bottom Bar: Send Button + Quick Emoji + Attach Link + WakeUp */
.mailru-send-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.mailru-btn-send {
    background-color: #5f7e9d !important;
    border: 1px solid #4a6787 !important;
    color: #ffffff !important;
    font-family: tahoma, verdana, arial, sans-serif !important;
    font-size: 11px !important;
    font-weight: normal !important;
    padding: 4px 16px !important;
    border-radius: 2px !important;
    cursor: pointer !important;
    text-align: center !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1.19 !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    outline: none !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    margin-left: auto;
    transition: background-color 0.15s, border-color 0.15s;
}

.mailru-btn-send:hover:not(:disabled) {
    background-color: #527094 !important;
    border-color: #3f5c7c !important;
}

.mailru-btn-send:active:not(:disabled) {
    background-color: #466282 !important;
    border-color: #385370 !important;
}

.mailru-btn-send:disabled {
    background-color: #9bb1c6 !important;
    border-color: #8fa5ba !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
    box-shadow: none !important;
}

.mailru-bottom-extra-links {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mailru-link-attach {
    background: transparent;
    border: none;
    color: #23527c;
    font-size: 12px;
    font-family: Tahoma, Arial, sans-serif;
    cursor: pointer;
    text-decoration: none;
    padding: 0;
}

.mailru-link-attach:hover {
    text-decoration: underline;
    color: #1a3e5e;
}

.mailru-btn-wakeup,
.mailru-sound-btn {
    background: transparent;
    border: none;
    color: #2b587a;
    font-size: 11px;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
    padding: 0;
    margin: 0;
    border-radius: 0;
    cursor: pointer;
    text-decoration: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    user-select: none;
    transition: color 0.1s ease;
}

.mailru-btn-wakeup:hover:not(:disabled),
.mailru-sound-btn:hover:not(:disabled) {
    background: transparent;
    color: #1a3e5e;
    text-decoration: underline;
}

.mailru-btn-wakeup:active:not(:disabled),
.mailru-sound-btn:active:not(:disabled) {
    color: #0e2a42;
}

.mailru-btn-wakeup:disabled,
.mailru-sound-btn:disabled {
    background: transparent;
    color: #8c9ba9;
    opacity: 0.6;
    cursor: not-allowed;
    text-decoration: none;
}

@media (max-width: 960px) {
    .chat-history {
        padding: 14px 0px 20px 64px;
    }
}

@media (max-width: 640px) {
    .chat-history {
        padding: 12px 0px 18px 24px;
    }

    .mailru-chat-send-box {
        padding: 8px 8px 6px 8px !important;
    }

    .mailru-send-main-row {
        gap: 8px;
    }

    .mailru-chat-avatar-side {
        width: 38px;
    }

    .mailru-side-avatar-img {
        width: 36px;
        height: 36px;
    }

    .mailru-send-bottom-bar {
        padding-left: 0;
        padding-right: 0;
        gap: 6px;
        flex-wrap: wrap;
    }
}

/* OpenVK Bridge Component */
.openvk-bridge-block {
    width: 100%;
}

.openvk-profile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    background-color: #f7f9fb;
    border: 1px solid #dce4eb;
    border-radius: 2px;
    box-sizing: border-box;
}

.openvk-avatar-wrap {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    position: relative;
    border-radius: 2px;
    overflow: hidden;
    background-color: #eef2f5;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.openvk-user-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.openvk-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #8294a5;
    background: #eef2f5;
    user-select: none;
}

.openvk-user-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.openvk-user-fullname {
    font-size: 11px;
    font-weight: bold;
    color: #2b587a;
    line-height: 1.19;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: tahoma, verdana, arial, sans-serif;
}

.openvk-user-name {
    font-size: 11px;
    font-weight: 500;
    color: #5181b8;
    line-height: 1.19;
    font-family: tahoma, verdana, arial, sans-serif;
}

.openvk-user-status-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    margin-top: 3px;
    color: #656565;
    line-height: 1.19;
    font-family: tahoma, verdana, arial, sans-serif;
}

.openvk-status-dot {
    width: 6px;
    height: 6px;
    background-color: #4bb34b;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.openvk-status-text {
    color: #2e7d32;
    font-weight: 500;
}

.openvk-sep-dot {
    color: #a0acb9;
    font-size: 10px;
}

.openvk-user-id {
    font-size: 11px;
    color: #7b8a99;
    font-family: monospace;
    line-height: 1.19;
}

.openvk-card-actions {
    flex-shrink: 0;
}

.openvk-unlinked-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    background-color: #f7f9fb;
    border: 1px solid #dce4eb;
    border-radius: 2px;
    box-sizing: border-box;
}

.openvk-unlinked-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.openvk-unlinked-title {
    font-size: 11px;
    font-weight: bold;
    color: #2b3a4a;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
}

.openvk-unlinked-desc {
    font-size: 11px;
    color: #656565;
    line-height: 1.35;
    font-family: tahoma, verdana, arial, sans-serif;
}

.openvk-unlinked-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.openvk-advanced-section {
    margin-top: 10px;
}

.openvk-advanced-toggle {
    color: #5181b8;
    text-decoration: none;
    font-size: 11px;
    font-family: tahoma, verdana, arial, sans-serif;
    line-height: 1.19;
    cursor: pointer;
    display: inline-block;
}

.openvk-advanced-toggle:hover {
    text-decoration: underline;
    color: #2a5885;
}

.openvk-config-card {
    background-color: #ffffff;
    border: 1px solid #dce4eb;
    border-radius: 2px;
    padding: 12px 14px;
    margin-top: 8px;
}

/* OpenVK Login Modal */
.openvk-modal-window {
    max-width: 440px !important;
    border-radius: 0 !important;
}

.openvk-auth-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #d3d9de;
    margin-bottom: 12px;
}

.openvk-auth-tab-btn {
    padding: 6px 12px;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    font-weight: normal;
    cursor: pointer;
    color: #656565;
    font-size: 12px;
    font-family: Tahoma, Arial, sans-serif;
    border-radius: 0;
}

.openvk-auth-tab-btn:hover {
    color: #2a5885;
}

.openvk-auth-tab-btn.active {
    color: #2a5885;
    border-bottom-color: #5181b8;
    font-weight: bold;
}

.openvk-modal-error {
    margin-bottom: 10px;
    padding: 6px 10px;
    background-color: #ffebee;
    border: 1px solid #ffcdd2;
    color: #c62828;
    font-size: 11px;
    border-radius: 0;
    font-family: Tahoma, Arial, sans-serif;
}

#ajloader {
    display: none;
    position: fixed;
    top: -10%;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 0px 0px 2px 0px black;
    padding: 0;
    width: 91px;
    height: 37px;
    line-height: 37px;
    text-align: center;
    border-radius: 2px;
    margin: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5555;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
}

#ajloader[style*="display: block"] {
    display: flex !important;
}

#ajloader img {
    vertical-align: middle;
    display: block;
    margin: 0 auto;
}




