/* Базовые сбросы стилей и переменные */
:root {
    --bg-color: #f4f6f9;
    --panel-bg: #ffffff;
    --primary-color: #0b2545; /* Темно-синий из логотипа */
    --accent-color: #139a8c;  /* Бирюзовый из логотипы */
    --text-color: #333333;
    --border-color: #e0e6ed;
    --sidebar-width: 260px;
    --header-height: 60px;
}

body.theme-dark {
    --bg-color: #111827;
    --panel-bg: #1f2937;
    --primary-color: #f9fafb;
    --accent-color: #22c55e;
    --text-color: #e5e7eb;
    --border-color: #374151;
}

body.theme-blue {
    --bg-color: #eef5ff;
    --panel-bg: #ffffff;
    --primary-color: #123a63;
    --accent-color: #2563eb;
    --text-color: #26364a;
    --border-color: #cfe0f5;
}

body.theme-warm {
    --bg-color: #fbf5eb;
    --panel-bg: #fffaf3;
    --primary-color: #4a2f1d;
    --accent-color: #d97706;
    --text-color: #46352a;
    --border-color: #ead9c3;
}

body.theme-premium {
    --bg-color: #07111f;
    --panel-bg: rgba(15, 27, 46, 0.84);
    --primary-color: #eaf6ff;
    --accent-color: #28d7c6;
    --text-color: #d9e8f6;
    --border-color: rgba(148, 199, 216, 0.18);
}

body.theme-dark .data-table th,
body.theme-dark .sidebar-menu li a:hover,
body.theme-dark .sidebar-menu li.active a,
body.theme-dark .user-dropdown-item:hover {
    background-color: #263244;
}

body.theme-dark .settings-field input,
body.theme-dark .modal-row input[type="text"],
body.theme-dark .modal-row input[type="password"],
body.theme-dark .modal-row select,
body.theme-dark .avatar-drop-zone {
    background: #111827;
    color: var(--text-color);
}

body.theme-dark .status-badge.badge-muted {
    background: #374151;
    color: #d1d5db;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    --section-color: var(--accent-color);
    --section-soft: rgba(19, 154, 140, 0.12);
    height: 100vh;
    display: grid;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    overflow: hidden;
}

html {
    overflow-x: hidden;
}

body.section-messenger {
    --section-color: #d97706;
    --section-soft: rgba(217, 119, 6, 0.14);
}

body.section-ai {
    --section-color: #7c3aed;
    --section-soft: rgba(124, 58, 237, 0.14);
}

body.section-storage {
    --section-color: #2563eb;
    --section-soft: rgba(37, 99, 235, 0.14);
}

body.section-admin {
    --section-color: #139a8c;
    --section-soft: rgba(19, 154, 140, 0.14);
}

body.section-settings {
    --section-color: #0f766e;
    --section-soft: rgba(15, 118, 110, 0.14);
}

/* --- ВЕРХНЯЯ ПАНЕЛЬ (HEADER) --- */
.top-navbar {
    grid-area: header;
    background-color: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
}

.top-nav-links {
    display: flex;
    gap: 8px;
    height: 100%;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 16px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    font-size: 15px;
    border-bottom: 3px solid transparent;
    position: relative;
    transition: all 0.2s ease;
}

.nav-icon {
    flex-shrink: 0;
}

.nav-item:hover {
    color: var(--section-color);
    background: var(--section-soft);
}

.nav-item.active {
    border-bottom-color: var(--section-color);
    color: var(--primary-color);
    background: var(--section-soft);
    box-shadow: inset 0 -1px 0 var(--section-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-profile:hover {
    background: #f0f2f5;
}

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

.user-profile-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-color);
}

.user-arrow-icon {
    color: #aaa;
    transition: transform 0.2s;
    flex-shrink: 0;
}

/* Кнопка гамбургера (по умолчанию скрыта) */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 100;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Анимация превращения гамбургера в крестик */
.menu-toggle.open span:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}
.menu-toggle.open span:nth-child(2) {
    opacity: 0;
}
.menu-toggle.open span:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}


/* --- БОКОВАЯ ПАНЕЛЬ (SIDEBAR) --- */
.sidebar {
    grid-area: sidebar;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: transform 0.3s ease;
}

.logo-container {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.site-logo {
    max-width: 90%;
    max-height: 100%;
    object-fit: contain;
}

.sidebar-menu {
    list-style: none;
    padding: 15px 0;
    overflow-y: auto;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: #555;
    text-decoration: none;
    font-size: 15px;
    border-left: 4px solid transparent;
    transition: all 0.2s;
}

.sidebar-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0.6;
}

.sidebar-menu li a:hover .sidebar-icon,
.sidebar-menu li.active a .sidebar-icon {
    opacity: 1;
}

.sidebar-menu li a:hover {
    background-color: #f0f4f8;
    color: var(--section-color);
    border-left-color: var(--section-color);
}


/* --- ОСНОВНОЙ КОНТЕНТ --- */
.main-content {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
    min-width: 0;
}

.content-card {
    background-color: var(--panel-bg);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    border-top: 4px solid var(--section-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    min-height: 400px;
    position: relative;
}

.sidebar-overlay {
    display: none;
}

.mobile-main-menu {
    display: none;
}

.mobile-current-section {
    display: none;
}

.mobile-section-switcher {
    display: none;
}


/* --- АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ (Экран < 768px) --- */
@media (max-width: 767px) {
    :root {
        --header-height: 56px;
        --sidebar-width: min(86vw, 320px);
    }

    body {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
        overflow: hidden;
    }

    body.menu-open {
        overflow: hidden;
    }

    .menu-toggle {
        display: flex;
        flex-shrink: 0;
    }

    .top-navbar {
        padding: 0 12px;
        gap: 10px;
    }

    .top-nav-links {
        display: none;
    }

    .mobile-section-switcher {
        display: block;
        position: relative;
        min-width: 0;
        max-width: 42vw;
        margin-left: auto;
    }

    .mobile-current-section {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: 100%;
        overflow: hidden;
        border: 1px solid color-mix(in srgb, var(--section-color) 35%, transparent);
        cursor: pointer;
        font-size: 14px;
        font-weight: 700;
        color: var(--primary-color);
        padding: 7px 10px;
        border-radius: 999px;
        background: var(--section-soft);
    }

    .mobile-current-section span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-current-section svg {
        flex-shrink: 0;
        transition: transform 0.2s ease;
    }

    .mobile-section-dropdown {
        display: none;
        position: fixed;
        top: calc(var(--header-height) + 8px);
        right: 58px;
        width: min(230px, calc(100vw - 76px));
        padding: 8px;
        background: var(--panel-bg);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        box-shadow: 0 12px 28px rgba(0,0,0,0.16);
        z-index: 50;
    }

    .mobile-section-dropdown.show {
        display: block;
    }

    .mobile-section-dropdown a {
        display: flex;
        align-items: center;
        gap: 9px;
        min-height: 40px;
        padding: 9px 12px;
        border-radius: 9px;
        color: var(--text-color);
        text-decoration: none;
        font-size: 14px;
        font-weight: 600;
    }

    .mobile-section-dropdown a:hover,
    .mobile-section-dropdown a.active {
        color: var(--section-color);
        background: var(--section-soft);
    }

    .user-menu-container {
        margin-left: 0;
        min-width: 0;
    }

    .user-profile {
        padding: 4px 6px;
        gap: 6px;
    }

    .user-profile-name {
        max-width: 92px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 13px;
    }

    .user-avatar-img {
        width: 30px;
        height: 30px;
    }

    .user-dropdown {
        position: fixed;
        top: calc(var(--header-height) + 8px);
        right: 10px;
        width: min(280px, calc(100vw - 20px));
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--sidebar-width);
        height: 100dvh;
        max-height: 100dvh;
        transform: translateX(-100%);
        box-shadow: 8px 0 24px rgba(0,0,0,0.18);
        z-index: 30;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .logo-container {
        justify-content: flex-start;
        padding: 10px 18px;
    }

    .site-logo {
        max-width: 150px;
    }

    .mobile-main-menu {
        display: none;
        padding: 12px 0;
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-main-menu summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 46px;
        padding: 0 18px 0 22px;
        color: var(--primary-color);
        font-size: 15px;
        font-weight: 700;
        cursor: pointer;
        list-style: none;
    }

    .mobile-main-menu summary::-webkit-details-marker {
        display: none;
    }

    .mobile-main-menu summary::after {
        content: "";
        width: 8px;
        height: 8px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        transition: transform 0.2s ease;
        opacity: 0.7;
    }

    .mobile-main-menu[open] summary::after {
        transform: rotate(225deg);
    }

    .mobile-menu-current {
        margin-left: auto;
        padding: 4px 9px;
        border-radius: 999px;
        background: var(--section-soft);
        color: var(--section-color);
        font-size: 12px;
        font-weight: 700;
    }

    .mobile-main-links {
        padding: 4px 0 8px;
    }

    .mobile-main-link {
        display: flex;
        align-items: center;
        padding: 12px 22px;
        color: var(--text-color);
        text-decoration: none;
        font-size: 15px;
        font-weight: 600;
        border-left: 4px solid transparent;
    }

    .mobile-main-link:hover,
    .mobile-main-link.active {
        color: var(--section-color);
        background: var(--section-soft);
        border-left-color: var(--section-color);
    }

    .sidebar-menu {
        padding: 10px 0 20px;
    }

    .sidebar-menu li a {
        min-height: 46px;
        padding: 12px 22px;
        font-size: 15px;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.48);
        z-index: 25;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        padding: 12px;
        overflow-x: hidden;
    }

    .content-card {
        padding: 16px;
        min-height: calc(100dvh - var(--header-height) - 24px);
        border-radius: 10px;
    }

    .page-header {
        gap: 12px;
        align-items: flex-start;
        margin-bottom: 16px;
    }

    .page-title,
    .page-header .page-title {
        font-size: 19px;
        line-height: 1.25;
    }

    .settings-block,
    .settings-block-wide {
        max-width: none;
        width: 100%;
    }

    .settings-block-header {
        gap: 10px;
        margin-bottom: 20px;
    }

    .settings-block-header h1 {
        font-size: 18px;
    }

    .settings-form,
    .avatar-form,
    .theme-form {
        width: 100%;
    }

    .settings-field input,
    .modal-row input[type="text"],
    .modal-row input[type="password"],
    .modal-row select {
        min-height: 42px;
        font-size: 16px;
    }

    .settings-actions {
        justify-content: stretch;
    }

    .btn-settings-save,
    .btn-modal-save,
    .btn-modal-cancel {
        min-height: 42px;
    }

    .settings-actions .btn-settings-save,
    .btn-avatar-upload {
        width: 100%;
        justify-content: center;
    }

    .avatar-section {
        flex-direction: column;
        gap: 22px;
    }

    .avatar-preview-wrap {
        align-items: flex-start;
    }

    .avatar-preview-img {
        width: 88px;
        height: 88px;
    }

    .avatar-drop-zone {
        padding: 24px 16px;
    }

    .theme-grid {
        grid-template-columns: 1fr;
    }

    .table-wrapper {
        margin: 0 -8px;
        padding: 0 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        font-size: 13px;
        min-width: 720px;
    }

    .data-table th,
    .data-table td {
        padding: 12px 14px;
    }

    .actions-cell {
        gap: 6px;
    }

    .btn-icon {
        width: 34px;
        height: 34px;
        margin: 0;
    }

    .table-pagination {
        justify-content: center;
        gap: 10px;
        margin-top: 18px;
        padding: 12px 10px;
        background: #f8fafc;
        border-radius: 12px;
        border: 1px solid #e2e8f0;
    }

    .page-link {
        min-width: 44px;
        height: 44px;
        padding: 0 12px;
        font-size: 16px;
        border-width: 2px;
        border-radius: 10px;
    }

    .page-link.is-active {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .modal-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .modal-card,
    .modal-card-sm {
        max-width: none;
        width: 100%;
        border-radius: 14px;
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
    }

    .modal-header {
        padding: 16px 18px 12px;
    }

    .modal-form {
        padding: 16px 18px;
    }

    .modal-footer,
    .modal-footer-confirm {
        padding: 10px 18px 18px;
        flex-direction: column-reverse;
    }

    .modal-footer .btn-modal-save,
    .modal-footer .btn-modal-cancel,
    .modal-footer a {
        width: 100%;
        justify-content: center;
    }

    .auth-card {
        width: min(420px, calc(100vw - 28px));
        padding: 24px 18px;
        border-radius: 14px;
    }

    .auth-button {
        min-height: 44px;
    }
}

@media (max-width: 420px) {
    .content-card {
        padding: 14px;
    }

    .mobile-section-switcher {
        max-width: 52vw;
    }

    .mobile-current-section {
        font-size: 13px;
        padding: 6px 9px;
    }

    .user-profile-name {
        display: none;
    }

    .user-arrow-icon {
        display: none;
    }

    .page-header {
        align-items: center;
    }
}

/* Оверлей авторизации */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.auth-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 350px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.auth-card h2 {
    margin-bottom: 20px;
    text-align: center;
    color: var(--primary-color);
}

.auth-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.auth-logo {
    max-width: 180px;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.top-logo-img {
    height: 40px;
    width: auto;
    display: block;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.auth-button {
    width: 100%;
    padding: 12px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
}

.auth-button:hover {
    filter: brightness(1.1);
}

.login-error {
    background: #fdecea;
    color: #c0392b;
    border: 1px solid #f0c8c4;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.user-menu-container {
    position: relative;
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 220px;
    z-index: 100;
    overflow: hidden;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f8fafc;
}

.user-dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}

.user-dropdown-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.user-dropdown-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-role {
    font-size: 12px;
    color: var(--accent-color);
    font-weight: 500;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-color);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.user-dropdown-item:hover {
    background: #f4f6f9;
    color: var(--primary-color);
}

.user-dropdown-logout {
    color: #c0392b;
}

.user-dropdown-logout:hover {
    background: #fdecea;
    color: #c0392b;
}
/* Правило для активного пункта меню */
.sidebar-menu li.active a {
    background-color: #f0f4f8;
    color: var(--section-color);
    border-left-color: var(--section-color);
    cursor: pointer;
}

/* --- ШАПКА СТРАНИЦЫ С КНОПКОЙ --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.page-header .page-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.page-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-add-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-add-user:hover {
    filter: brightness(1.1);
}

.btn-add-universal {
    width: 42px;
    height: 42px;
    padding: 0;
    gap: 0;
    border-radius: 12px;
    justify-content: center;
    border: 1px solid #0f8c81;
    box-shadow: 0 4px 10px rgba(19, 154, 140, 0.22);
    flex-shrink: 0;
}

.page-header .btn-add-universal {
    margin-right: 6px;
}

.btn-add-universal svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.7;
}

.btn-add-universal:hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 16px rgba(19, 154, 140, 0.28);
}

.btn-add-universal:active {
    transform: translateY(0);
}

.btn-table-settings {
    background: #f4f6f9;
    color: var(--primary-color);
    border-color: var(--border-color);
    box-shadow: none;
}

.btn-table-settings:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    background: #f0faf9;
    box-shadow: 0 6px 14px rgba(19, 154, 140, 0.14);
}

/* --- МОДАЛЬНОЕ ОКНО --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

/* Диалог конфликта имён — поверх move/copy/restore и других модалок */
#kbConflictModal {
    z-index: 400;
}

.modal-card {
    background: white;
    border-radius: 10px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 4px;
    display: flex;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
    background: #f0f2f5;
    color: var(--primary-color);
}

.modal-form {
    padding: 20px 24px;
}

.modal-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.modal-row label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.modal-row input[type="text"],
.modal-row input[type="password"],
.modal-row select {
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s;
}

.modal-row input:focus,
.modal-row select:focus {
    border-color: var(--accent-color);
}

.modal-row-check {
    margin-bottom: 8px;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 400 !important;
    cursor: pointer;
}

.check-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.req {
    color: #c0392b;
}

.form-error-msg {
    margin: 0 24px 0;
    padding: 10px 14px;
    background: #fdecea;
    color: #c0392b;
    border-radius: 6px;
    font-size: 13px;
    border-left: 3px solid #c0392b;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

.modal-footer-confirm {
    padding: 0 24px 20px;
}

.btn-modal-cancel {
    padding: 9px 18px;
    background: #f0f2f5;
    color: #555;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-modal-cancel:hover {
    background: #e0e4ea;
}

.btn-modal-save {
    padding: 9px 22px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-modal-save:hover {
    filter: brightness(1.1);
}

.btn-modal-danger {
    background: linear-gradient(180deg, #ef5a4c 0%, #e74c3c 100%);
    border: 1px solid #d84335;
    box-shadow: 0 3px 8px rgba(231, 76, 60, 0.28);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-modal-danger:hover {
    filter: brightness(1.03);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(231, 76, 60, 0.32);
}

.btn-modal-danger:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.26);
}

.modal-card-sm {
    max-width: 380px;
}

.confirm-body {
    padding: 16px 24px 20px;
    font-size: 15px;
    color: var(--text-color);
    line-height: 1.5;
}

.msg-confirm-overlay {
    background: rgba(15, 23, 42, 0.38);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.msg-confirm-overlay.active {
    animation: msgConfirmFadeIn 0.22s ease;
}

.msg-confirm-card {
    border-radius: 16px;
    max-width: 400px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
    animation: msgConfirmSlideIn 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.msg-confirm-header {
    padding: 18px 22px 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
}

.msg-confirm-header h2 {
    font-size: 17px;
}

.msg-confirm-body {
    padding: 18px 22px 22px;
    font-size: 14px;
    line-height: 1.55;
    color: #475569;
}

.msg-confirm-overlay .modal-footer-confirm {
    padding: 0 22px 20px;
    gap: 8px;
}

.msg-confirm-overlay .btn-modal-cancel,
.msg-confirm-overlay .btn-modal-save {
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 14px;
}

@keyframes msgConfirmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes msgConfirmSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.field-hint {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

/* --- НАСТРОЙКИ --- */
.settings-block {
    max-width: 520px;
}

.settings-block-wide {
    max-width: 860px;
}

.settings-block-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 28px;
    border-bottom: 2px solid var(--border-color);
    color: var(--primary-color);
}

.settings-block-header h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.settings-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 7px;
    font-size: 14px;
    margin-bottom: 22px;
}

.settings-msg-success {
    background: #e8f7f0;
    color: #1a7a4a;
    border: 1px solid #b2dfc8;
}

.settings-msg-error {
    background: #fdecea;
    color: #c0392b;
    border: 1px solid #f0c8c4;
}

.kb-transfer-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 18px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: #eef4ff;
    border: 1px solid #c7d8ff;
    color: #1e3a6e;
    font-size: 14px;
}

.kb-transfer-banner-text strong {
    font-weight: 600;
}

.kb-transfer-banner-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.kb-transfer-decline-form {
    margin: 0;
}

.kb-transfer-hint {
    margin: 0 0 8px;
    font-size: 13px;
    color: #666;
    line-height: 1.45;
}

.kb-restore-hint {
    margin: 0 0 12px;
    padding: 10px 12px;
    font-size: 13px;
    color: #444;
    line-height: 1.45;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.kb-trash-loc {
    display: block;
    font-size: 12px;
    color: #64748b;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kb-share-readonly-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: #666;
    line-height: 1.45;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.settings-field label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.settings-field input {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    font-size: 14px;
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafbfc;
}

.settings-field input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(19,154,140,0.1);
    background: #fff;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.btn-settings-save {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-settings-save:hover {
    filter: brightness(1.08);
}

.btn-avatar-upload {
    background: #cfd8dc;
    color: #fff;
    cursor: not-allowed;
    pointer-events: none;
    transition: background 0.2s, filter 0.2s;
}

.btn-avatar-upload:disabled {
    background: #cfd8dc;
    color: #fff;
    cursor: not-allowed;
    pointer-events: none;
    filter: none;
}

.btn-avatar-upload.is-ready {
    background: var(--accent-color);
    cursor: pointer;
    pointer-events: auto;
}

.btn-avatar-upload.is-ready:hover {
    filter: brightness(1.08);
}

.btn-avatar-upload.is-loading {
    background: #8ea3ad;
    cursor: wait;
}

.btn-avatar-upload .btn-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: avatar-spin 0.8s linear infinite;
}

.btn-avatar-upload.is-loading .btn-spinner {
    display: inline-block;
}

.btn-avatar-upload.is-loading > svg {
    display: none;
}

@keyframes avatar-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.avatar-upload-status {
    display: none;
    margin-top: 8px;
    text-align: right;
    font-size: 13px;
    color: #5f6c73;
}

.avatar-upload-status.is-visible {
    display: block;
}

/* Аватар */
.avatar-section {
    display: flex;
    gap: 36px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.avatar-preview-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.avatar-preview-img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-color);
    transition: border-color 0.2s;
}

.avatar-preview-img:hover {
    border-color: var(--accent-color);
}

.avatar-preview-label {
    font-size: 12px;
    color: #888;
}

.avatar-form {
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.avatar-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 20px;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    background: #fafbfc;
}

.avatar-drop-zone:hover,
.avatar-drop-zone.drag-over {
    border-color: var(--accent-color);
    background: #f0faf9;
}

.avatar-drop-zone.has-file {
    border-color: var(--accent-color);
}

.avatar-drop-icon {
    color: #aab;
    transition: color 0.2s;
}

.avatar-drop-zone:hover .avatar-drop-icon,
.avatar-drop-zone.has-file .avatar-drop-icon {
    color: var(--accent-color);
}

.avatar-drop-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    word-break: break-all;
}

.avatar-drop-hint {
    font-size: 12px;
    color: #aaa;
}

/* --- ВЫБОР ДИЗАЙНА --- */
.theme-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
}

.theme-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--panel-bg);
    padding: 12px;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.theme-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.theme-card.is-selected {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(19,154,140,0.16), 0 10px 24px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.theme-selected-badge {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--accent-color);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0,0,0,0.16);
}

.theme-card.is-selected .theme-selected-badge {
    display: inline-flex;
}

.theme-card input {
    display: none;
}

.theme-preview {
    height: 118px;
    border-radius: 9px;
    overflow: hidden;
    display: grid;
    grid-template-columns: 54px 1fr;
    background: var(--preview-bg);
    border: 1px solid rgba(0,0,0,0.08);
}

.theme-preview-sidebar {
    background: var(--preview-panel);
    border-right: 1px solid rgba(0,0,0,0.08);
    position: relative;
}

.theme-preview-sidebar::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 16px;
    width: 30px;
    height: 8px;
    border-radius: 6px;
    background: var(--preview-accent);
    opacity: 0.9;
}

.theme-preview-main {
    padding: 12px;
}

.theme-preview-top {
    height: 12px;
    border-radius: 8px;
    background: var(--preview-panel);
    margin-bottom: 12px;
}

.theme-preview-card {
    height: 34px;
    border-radius: 8px;
    background: var(--preview-panel);
    margin-bottom: 10px;
}

.theme-preview-row,
.theme-preview-row.short {
    height: 8px;
    border-radius: 8px;
    background: var(--preview-primary);
    opacity: 0.7;
    margin-bottom: 7px;
}

.theme-preview-row.short {
    width: 64%;
    background: var(--preview-accent);
}

.theme-card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 2px 2px;
}

.theme-card-info strong {
    font-size: 14px;
    color: var(--primary-color);
}

.theme-card-info span {
    font-size: 12px;
    line-height: 1.4;
    color: #888;
}

.theme-actions {
    justify-content: flex-start;
}

/* --- ТАБЛИЦЫ --- */
.page-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.table-wrapper {
    overflow-x: auto;
}

.table-pagination {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.page-link {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d7dde4;
    border-radius: 8px;
    background: #fff;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.page-link:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: #f0faf9;
}

.page-link.is-active {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: #fff;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.data-table th {
    background-color: #f4f6f9;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
    padding: 16px 28px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 16px 28px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-color);
    white-space: nowrap;
}

/* Минимальная ширина колонок */
.data-table th:nth-child(1),
.data-table td:nth-child(1) { min-width: 50px; }   /* N */

.data-table th:nth-child(2),
.data-table td:nth-child(2) { min-width: 120px; }  /* Логин */

.data-table th:nth-child(3),
.data-table td:nth-child(3) { min-width: 180px; }  /* Имя пользователя */

.data-table th:nth-child(4),
.data-table td:nth-child(4) { min-width: 160px; }  /* Группа */

.data-table th:nth-child(5),
.data-table td:nth-child(5) { min-width: 90px; }   /* Блок */

.data-table th:nth-child(6),
.data-table td:nth-child(6) { min-width: 90px; }   /* Админ */

.data-table th:nth-child(7),
.data-table td:nth-child(7) { min-width: 170px; }  /* Последний вход */

.data-table th:nth-child(8),
.data-table td:nth-child(8) { min-width: 160px; }  /* Действия */

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background-color: #f8fafc;
}

.data-table .empty-row {
    text-align: center;
    color: #888;
    padding: 32px;
}

.form-error-inline {
    margin: 0 0 12px;
}

.actions-cell {
    white-space: nowrap;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    text-decoration: none;
    margin: 0 3px;
    transition: background-color 0.2s, color 0.2s;
}

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

.group-col-n {
    width: 60px;
}

.group-col-users,
.group-col-actions {
    text-align: center !important;
}

.group-col-users {
    width: 140px;
}

.group-col-actions {
    width: 120px;
}

.btn-icon-edit {
    color: var(--accent-color);
    background-color: #f0faf9;
    border: 1px solid #c5ebe7;
}

.btn-icon-edit:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.btn-icon-delete {
    color: #c0392b;
    background-color: #fdf5f5;
    border: 1px solid #f0c8c4;
}

.btn-icon-delete:hover {
    background-color: #c0392b;
    color: white;
    border-color: #c0392b;
}

.btn-icon-block {
    color: #e67e22;
    background-color: #fdf8f0;
    border: 1px solid #f5d5a8;
}

.btn-icon-block:hover {
    background-color: #e67e22;
    color: white;
    border-color: #e67e22;
}

.btn-icon-unblock {
    color: #27ae60;
    background-color: #f0faf4;
    border: 1px solid #a8dbb8;
}

.btn-icon-unblock:hover {
    background-color: #27ae60;
    color: white;
    border-color: #27ae60;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background-color: #e6f7f4;
    color: #0d7a6e;
}

.badge-danger {
    background-color: #fdecea;
    color: #c0392b;
}

.badge-info {
    background-color: #e8f0fd;
    color: #0b2545;
}

.badge-muted {
    background-color: #f0f2f5;
    color: #888;
}

/* --- БАЗА ЗНАНИЙ: ДОКУМЕНТЫ И ФОТО --- */
.kb-search {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px;
    margin-bottom: 20px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

.kb-search .settings-field {
    min-width: 180px;
}

.btn-storage-primary,
.btn-storage-secondary {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border-radius: 9px;
    border: none;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.btn-storage-primary {
    background: var(--accent-color);
    color: #fff;
}

.btn-storage-secondary {
    background: #eef2f6;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.kb-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.kb-form-grid {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(220px, 1fr);
    gap: 16px;
}

.kb-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 170px;
    padding: 26px 18px;
    border: 2px dashed var(--border-color);
    border-radius: 18px;
    background: #fafbfc;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.kb-upload-zone:hover {
    border-color: var(--accent-color);
    background: #f0faf9;
    transform: translateY(-1px);
}

.kb-upload-zone input {
    display: none;
}

.kb-upload-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    font-size: 28px;
    line-height: 1;
}

.kb-upload-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
}

.kb-upload-hint {
    font-size: 13px;
    color: #888;
}

.kb-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 22px 0;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #f8fafc;
    color: #667085;
    font-size: 13px;
}

.kb-gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 26px 0 14px;
}

.kb-gallery-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--primary-color);
}

.kb-gallery-header span {
    color: #888;
    font-size: 13px;
}

.kb-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.kb-photo-card {
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--panel-bg);
    box-shadow: 0 8px 18px rgba(0,0,0,0.06);
}

.kb-photo-card img {
    width: 100%;
    height: 120px;
    display: block;
    object-fit: cover;
}

.kb-photo-actions {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: #f8fafc;
}

.kb-photo-actions a,
.kb-photo-actions button {
    border: none;
    background: transparent;
    color: var(--accent-color);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.kb-photo-actions button {
    color: #c0392b;
}

.kb-empty {
    grid-column: 1 / -1;
    padding: 26px;
    text-align: center;
    color: #888;
    border: 1px dashed var(--border-color);
    border-radius: 14px;
}

.kb-table-photo {
    width: 52px;
    height: 52px;
    position: relative;
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #f1f5f9;
}

button.kb-table-photo {
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    line-height: 0;
    cursor: pointer;
    vertical-align: middle;
}

.kb-table-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 12px;
    display: block;
}

.kb-table-photo span {
    position: absolute;
    inset: auto 6px 6px auto;
    min-width: 24px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(0,0,0,0.72);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}

.kb-journal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #f8fafc;
}

.kb-journal-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.kb-journal-meta strong {
    font-size: 15px;
    color: var(--primary-color);
}

.kb-journal-meta span {
    font-size: 12px;
    color: #6b7280;
}

.kb-journal-search {
    width: 220px;
    height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--primary-color);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.kb-journal-filter-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.kb-journal-search.kb-journal-date {
    width: 138px;
}

.kb-journal-search.kb-journal-comment {
    width: 230px;
}

.kb-journal-filter-btn {
    min-height: 38px;
    height: 38px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.kb-header-filters {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.kb-header-filters .kb-journal-search.kb-journal-date {
    width: 130px;
}

.kb-header-filters .kb-journal-search.kb-journal-comment {
    width: 160px;
}

.kb-journal-search:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(8, 138, 152, 0.14);
}

.kb-journal-table th:nth-child(1),
.kb-journal-table td:nth-child(1) { width: 72px; min-width: 72px; }
.kb-journal-table th:nth-child(2),
.kb-journal-table td:nth-child(2) { width: 160px; min-width: 160px; }
.kb-journal-table th:nth-child(3),
.kb-journal-table td:nth-child(3) { width: 72px; min-width: 72px; }
.kb-journal-table th:nth-child(4),
.kb-journal-table td:nth-child(4) { min-width: 220px; }
.kb-journal-table th:nth-child(5),
.kb-journal-table td:nth-child(5) { width: 120px; min-width: 120px; }

.kb-journal-table .actions-cell {
    display: table-cell;
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
}

.kb-journal-table tbody td {
    vertical-align: middle;
}

.kb-journal-table .actions-cell form {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.kb-journal-table .actions-cell > .btn-icon,
.kb-journal-table .actions-cell > form {
    vertical-align: middle;
    margin: 0 3px;
}

.kb-journal-table .actions-cell .btn-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kb-journal-table .actions-cell .btn-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

@media (max-width: 900px) {
    .kb-journal-head {
        flex-direction: column;
        align-items: stretch;
    }
    .kb-journal-filter-form {
        justify-content: stretch;
    }
    .kb-journal-search,
    .kb-journal-search.kb-journal-date,
    .kb-journal-search.kb-journal-comment,
    .kb-journal-filter-btn {
        width: 100%;
    }
}

.actions-cell form {
    display: inline-flex;
    margin: 0;
}

.actions-cell button.btn-icon {
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    line-height: 1;
    font: inherit;
    background-clip: padding-box;
    cursor: pointer;
}

body.theme-premium .kb-search,
body.theme-premium .kb-meta,
body.theme-premium .kb-upload-zone,
body.theme-premium .kb-photo-card,
body.theme-premium .kb-photo-actions,
body.theme-premium .kb-table-photo,
body.theme-premium .kb-journal-head {
    background: rgba(255,255,255,0.045);
    border-color: rgba(148, 199, 216, 0.18);
}

body.theme-premium .kb-journal-meta strong {
    color: #f8fdff;
}

body.theme-premium .kb-journal-meta span {
    color: rgba(217, 232, 246, 0.64);
}

body.theme-premium .kb-journal-search {
    background: rgba(4, 19, 36, 0.65);
    border-color: rgba(148, 199, 216, 0.24);
    color: #dfeeff;
}

body.theme-premium .kb-upload-zone:hover {
    background: rgba(40, 215, 198, 0.09);
    border-color: rgba(40, 215, 198, 0.56);
}

body.theme-premium .kb-upload-title,
body.theme-premium .kb-gallery-header h2 {
    color: #f8fdff;
}

body.theme-premium .kb-upload-hint,
body.theme-premium .kb-gallery-header span,
body.theme-premium .kb-meta,
body.theme-premium .kb-empty {
    color: rgba(217, 232, 246, 0.64);
}

/* --- SMART5 PREMIUM THEME --- */
body.theme-premium {
    background:
        radial-gradient(circle at 18% 12%, rgba(40, 215, 198, 0.18), transparent 34%),
        radial-gradient(circle at 82% 0%, rgba(45, 105, 255, 0.20), transparent 36%),
        linear-gradient(135deg, #050b15 0%, #07111f 45%, #0e1a2b 100%);
    color: var(--text-color);
}

body.theme-premium::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent 78%);
    z-index: 0;
}

body.theme-premium.section-messenger {
    --section-color: #f3b35b;
    --section-soft: rgba(243, 179, 91, 0.16);
}

body.theme-premium.section-ai {
    --section-color: #a78bfa;
    --section-soft: rgba(167, 139, 250, 0.18);
}

body.theme-premium.section-storage {
    --section-color: #60a5fa;
    --section-soft: rgba(96, 165, 250, 0.17);
}

body.theme-premium.section-admin,
body.theme-premium.section-settings {
    --section-color: #28d7c6;
    --section-soft: rgba(40, 215, 198, 0.16);
}

body.theme-premium .top-navbar,
body.theme-premium .sidebar,
body.theme-premium .content-card,
body.theme-premium .auth-card,
body.theme-premium .user-dropdown,
body.theme-premium .modal-card,
body.theme-premium .modal-card-sm,
body.theme-premium .theme-card {
    background: linear-gradient(180deg, rgba(18, 32, 53, 0.88), rgba(10, 19, 33, 0.84));
    border-color: rgba(148, 199, 216, 0.18);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255,255,255,0.07);
    backdrop-filter: blur(18px);
}

body.theme-premium .top-navbar,
body.theme-premium .sidebar,
body.theme-premium .main-content {
    position: relative;
    z-index: 1;
}

body.theme-premium .top-navbar {
    border-bottom: 1px solid rgba(40, 215, 198, 0.18);
    z-index: 80;
}

body.theme-premium .sidebar {
    border-right: 1px solid rgba(40, 215, 198, 0.16);
    z-index: 30;
}

body.theme-premium .main-content {
    z-index: 1;
}

body.theme-premium .user-menu-container {
    z-index: 120;
}

body.theme-premium .user-dropdown {
    z-index: 1000;
}

body.theme-premium .logo-container {
    background: radial-gradient(circle at center, rgba(40, 215, 198, 0.10), transparent 68%);
    border-bottom-color: rgba(148, 199, 216, 0.16);
}

body.theme-premium .site-logo {
    filter: drop-shadow(0 0 16px rgba(40, 215, 198, 0.24));
}

body.theme-premium .content-card {
    border-radius: 24px;
    border-top: 1px solid rgba(40, 215, 198, 0.38);
    padding: 30px;
}

body.theme-premium .content-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(40, 215, 198, 0.18), transparent 32%),
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.16), transparent 34%);
    opacity: 0.85;
}

body.theme-premium .content-card > * {
    position: relative;
    z-index: 1;
}

body.theme-premium .nav-item {
    border: 1px solid transparent;
    border-radius: 999px;
    margin: 10px 0;
    height: calc(100% - 20px);
    padding: 0 18px;
    color: rgba(217, 232, 246, 0.82);
}

body.theme-premium .nav-item:hover,
body.theme-premium .nav-item.active {
    color: #f8fdff;
    border-color: rgba(40, 215, 198, 0.28);
    background: linear-gradient(135deg, rgba(40, 215, 198, 0.16), rgba(96, 165, 250, 0.10));
    box-shadow: 0 12px 28px rgba(40, 215, 198, 0.12), inset 0 1px 0 rgba(255,255,255,0.08);
}

body.theme-premium .sidebar-menu li a,
body.theme-premium .sidebar-menu li.active a {
    margin: 4px 12px;
    border-left: 0;
    border-radius: 14px;
    color: rgba(217, 232, 246, 0.78);
}

body.theme-premium .sidebar-menu li a:hover,
body.theme-premium .sidebar-menu li.active a {
    color: #f8fdff;
    background: linear-gradient(135deg, var(--section-soft), rgba(96, 165, 250, 0.09));
    box-shadow: inset 0 0 0 1px rgba(40, 215, 198, 0.18), 0 10px 24px rgba(0,0,0,0.18);
}

body.theme-premium .sidebar-icon,
body.theme-premium .nav-icon {
    color: var(--section-color);
    filter: drop-shadow(0 0 8px color-mix(in srgb, var(--section-color) 32%, transparent));
}

body.theme-premium .user-profile {
    border: 1px solid rgba(148, 199, 216, 0.16);
    border-radius: 999px;
    background: rgba(255,255,255,0.035);
}

body.theme-premium .user-profile:hover,
body.theme-premium .user-dropdown-header,
body.theme-premium .user-dropdown-item:hover {
    background: rgba(40, 215, 198, 0.10);
}

body.theme-premium .user-avatar-img,
body.theme-premium .user-dropdown-avatar,
body.theme-premium .avatar-preview-img {
    border-color: rgba(40, 215, 198, 0.58);
    box-shadow: 0 0 0 4px rgba(40, 215, 198, 0.10), 0 10px 30px rgba(0,0,0,0.28);
}

body.theme-premium .user-dropdown-name,
body.theme-premium .page-title,
body.theme-premium .settings-block-header,
body.theme-premium .settings-block-header h1,
body.theme-premium .modal-header h2,
body.theme-premium .theme-card-info strong,
body.theme-premium .auth-card h2 {
    color: #f8fdff;
}

body.theme-premium .page-header,
body.theme-premium .settings-block-header,
body.theme-premium .modal-header,
body.theme-premium .user-dropdown-divider {
    border-color: rgba(148, 199, 216, 0.16);
}

body.theme-premium .btn-add-user,
body.theme-premium .btn-add-universal,
body.theme-premium .btn-settings-save,
body.theme-premium .btn-modal-save,
body.theme-premium .auth-button,
body.theme-premium .page-link.is-active {
    background: linear-gradient(135deg, #28d7c6 0%, #3b82f6 100%);
    border: 1px solid rgba(255,255,255,0.16);
    box-shadow: 0 14px 34px rgba(40, 215, 198, 0.22), inset 0 1px 0 rgba(255,255,255,0.26);
    color: #03101b;
    font-weight: 800;
}

body.theme-premium .btn-add-user:hover,
body.theme-premium .btn-add-universal:hover,
body.theme-premium .btn-settings-save:hover,
body.theme-premium .btn-modal-save:hover,
body.theme-premium .auth-button:hover {
    filter: none;
    transform: translateY(-1px);
    box-shadow: 0 18px 40px rgba(40, 215, 198, 0.30), inset 0 1px 0 rgba(255,255,255,0.30);
}

body.theme-premium .btn-table-settings,
body.theme-premium .btn-modal-cancel,
body.theme-premium .page-link {
    background: rgba(255,255,255,0.055);
    color: #d9e8f6;
    border-color: rgba(148, 199, 216, 0.20);
}

body.theme-premium .btn-table-settings:hover,
body.theme-premium .btn-modal-cancel:hover,
body.theme-premium .page-link:hover {
    color: #28d7c6;
    background: rgba(40, 215, 198, 0.10);
    border-color: rgba(40, 215, 198, 0.42);
}

body.theme-premium .data-table {
    border-spacing: 0 10px;
}

body.theme-premium .data-table th {
    background: rgba(255,255,255,0.045);
    color: rgba(234, 246, 255, 0.88);
    border-bottom: 0;
}

body.theme-premium .data-table td {
    background: rgba(255,255,255,0.035);
    border-bottom: 1px solid rgba(148, 199, 216, 0.10);
}

body.theme-premium .data-table tbody tr:hover td {
    background: rgba(40, 215, 198, 0.075);
}

body.theme-premium .data-table th:first-child,
body.theme-premium .data-table td:first-child {
    border-radius: 14px 0 0 14px;
}

body.theme-premium .data-table th:last-child,
body.theme-premium .data-table td:last-child {
    border-radius: 0 14px 14px 0;
}

body.theme-premium .settings-field input,
body.theme-premium .form-group input[type="text"],
body.theme-premium .form-group input[type="password"],
body.theme-premium .modal-row input[type="text"],
body.theme-premium .modal-row input[type="password"],
body.theme-premium .modal-row select,
body.theme-premium .avatar-drop-zone {
    background: rgba(255,255,255,0.055);
    border-color: rgba(148, 199, 216, 0.20);
    color: #f8fdff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

body.theme-premium .settings-field input:focus,
body.theme-premium .form-group input:focus,
body.theme-premium .modal-row input:focus,
body.theme-premium .modal-row select:focus {
    border-color: rgba(40, 215, 198, 0.70);
    box-shadow: 0 0 0 4px rgba(40, 215, 198, 0.14);
    background: rgba(255,255,255,0.075);
}

body.theme-premium .settings-field label,
body.theme-premium .form-group label,
body.theme-premium .modal-row label,
body.theme-premium .field-hint,
body.theme-premium .avatar-drop-hint,
body.theme-premium .theme-card-info span,
body.theme-premium .avatar-preview-label {
    color: rgba(217, 232, 246, 0.64);
}

body.theme-premium .avatar-drop-zone:hover,
body.theme-premium .avatar-drop-zone.drag-over,
body.theme-premium .avatar-drop-zone.has-file {
    background: rgba(40, 215, 198, 0.09);
    border-color: rgba(40, 215, 198, 0.56);
}

body.theme-premium .status-badge,
body.theme-premium .theme-selected-badge {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}

body.theme-premium .badge-success {
    background: rgba(40, 215, 198, 0.15);
    color: #55f5df;
}

body.theme-premium .badge-danger {
    background: rgba(248, 113, 113, 0.15);
    color: #fca5a5;
}

body.theme-premium .badge-info {
    background: rgba(96, 165, 250, 0.16);
    color: #bfdbfe;
}

body.theme-premium .badge-muted {
    background: rgba(148, 163, 184, 0.14);
    color: #cbd5e1;
}

body.theme-premium .theme-card:hover,
body.theme-premium .theme-card.is-selected {
    border-color: rgba(40, 215, 198, 0.52);
    box-shadow: 0 20px 44px rgba(0,0,0,0.32), 0 0 0 3px rgba(40, 215, 198, 0.12);
}

body.theme-premium .theme-preview {
    border-color: rgba(255,255,255,0.10);
}

body.theme-premium .modal-overlay {
    background: rgba(2, 6, 13, 0.72);
    backdrop-filter: blur(10px);
}

body.theme-premium .form-error-msg,
body.theme-premium .login-error,
body.theme-premium .settings-msg-error {
    background: rgba(248, 113, 113, 0.13);
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.26);
}

body.theme-premium .settings-msg-success {
    background: rgba(40, 215, 198, 0.13);
    color: #a7fff1;
    border-color: rgba(40, 215, 198, 0.28);
}

@media (max-width: 767px) {
    body.theme-premium .content-card {
        border-radius: 18px;
        padding: 18px;
    }

    body.theme-premium .mobile-current-section,
    body.theme-premium .mobile-section-dropdown {
        background: rgba(15, 27, 46, 0.94);
        border-color: rgba(40, 215, 198, 0.24);
        box-shadow: 0 18px 36px rgba(0,0,0,0.34);
    }

    body.theme-premium .sidebar-overlay {
        background: rgba(2, 6, 13, 0.68);
        backdrop-filter: blur(6px);
    }
}
/* ═══════════════════════════════════════════════════════════════════
   БАЗА ЗНАНИЙ — файловый менеджер
   ═══════════════════════════════════════════════════════════════════ */

/* Группа в боковом меню */
.sidebar-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 14px 18px 4px;
    cursor: default;
    pointer-events: none;
    user-select: none;
}

/* ── Шапка страницы ───────────────────────────────────────────── */
.kb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.kb-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    font-size: 14px;
}
.kb-breadcrumb a {
    color: var(--primary, #3b82f6);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}
.kb-breadcrumb a:hover { text-decoration: underline; }
.kb-crumb-sep {
    color: #94a3b8;
    font-size: 16px;
    line-height: 1;
}
.kb-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex: 1;
    justify-content: flex-end;
}
.kb-header-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}
.kb-header-add-btn { flex-shrink: 0; }
.kb-view-btn {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 7px 9px;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    transition: background .15s, color .15s;
}
.kb-view-btn:hover { background: #f1f5f9; color: #1e293b; }

/* ── Кнопка «Создать» с выпадашкой ──────────────────────────── */
.kb-create-wrapper { position: relative; }
.kb-create-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.kb-create-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    min-width: 190px;
    padding: 6px;
    z-index: 900;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity .15s, transform .15s;
}
.kb-create-menu.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.kb-create-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    text-align: left;
    transition: background .1s;
}
.kb-create-item:hover { background: #f1f5f9; }

/* ── Браузер ──────────────────────────────────────────────────── */
.kb-browser { min-height: 200px; }
.kb-section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 10px;
    margin-top: 4px;
}
.kb-section-label + .kb-section-label,
.kb-grid + .kb-section-label { margin-top: 28px; }

/* ── Grid ────────────────────────────────────────────────────── */
.kb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}
.kb-item {
    position: relative;
    border: 1px solid #e8edf4;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s, transform .1s;
}
.kb-item:hover {
    border-color: #c7d7ea;
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
    transform: translateY(-1px);
}
.kb-item-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 14px 14px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    user-select: none;
}
.kb-file-click { cursor: pointer; }
.kb-item-icon {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.kb-item-icon svg { width: 28px; height: 28px; }
.kb-item-icon.kb-thumb {
    padding: 0;
    overflow: hidden;
    background: #f1f5f9;
}
.kb-item-icon.kb-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}

/* Карточки с превью изображений — крупнее и понятнее */
.kb-item-has-preview .kb-item-inner {
    padding: 8px 8px 12px;
}
.kb-item-has-preview .kb-item-icon.kb-thumb {
    width: 100%;
    height: 118px;
    border-radius: 10px;
    margin-bottom: 8px;
}
.kb-item-has-preview .kb-item-icon.kb-thumb img {
    object-fit: cover;
    background: #f8fafc;
    border-radius: 10px;
}
.kb-item-has-preview .kb-shared-badge {
    top: auto;
    left: 8px;
    right: auto;
    bottom: 8px;
    width: 22px;
    height: 22px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.96);
    border-color: #bfdbfe;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.18);
}
.kb-item-has-preview .kb-shared-badge svg {
    width: 12px !important;
    height: 12px !important;
}

.kb-grid.kb-list .kb-item-icon.kb-thumb img {
    border-radius: 8px;
}
.kb-item-info { width: 100%; text-align: center; }
.kb-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.3;
}
.kb-ext { font-weight: 400; color: #94a3b8; }
.kb-item-meta {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 3px;
    white-space: nowrap;
}

/* Иконки папок/файлов: цвета */
.kb-icon-folder { background: #fffbeb; color: #f59e0b; }
.kb-icon-img    { background: #eff6ff; color: #3b82f6; }
.kb-icon-pdf    { background: #fef2f2; color: #ef4444; }
.kb-icon-word   { background: #eff6ff; color: #2563eb; }
.kb-icon-excel  { background: #f0fdf4; color: #16a34a; }
.kb-icon-ppt    { background: #fff7ed; color: #ea580c; }
.kb-icon-txt    { background: #f8fafc; color: #64748b; }
.kb-icon-zip    { background: #fefce8; color: #ca8a04; }
.kb-icon-video  { background: #f5f3ff; color: #7c3aed; }
.kb-icon-audio  { background: #fdf4ff; color: #a21caf; }
.kb-icon-file   { background: #f8fafc; color: #94a3b8; }

/* Кнопка «три точки» и значок «поделились» */
.kb-shared-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.kb-shared-badge svg { width: 11px !important; height: 11px !important; }
.kb-owner-tag { color: #64748b; font-weight: 500; }
.kb-share-access-list {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}
.kb-share-access-list .kb-access-row { margin-bottom: 6px; }

.kb-conflict-text {
    margin: 0 0 4px;
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
}

.kb-move-tree {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    padding: 8px;
}
.kb-move-node {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 2px 0;
    padding: 8px 10px;
    padding-left: calc(10px + var(--kb-move-depth, 0) * 16px);
    border: 1px solid transparent;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: border-color .12s, background .12s;
}
.kb-move-node:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}
.kb-move-node.is-selected {
    border-color: var(--accent-color, #3b82f6);
    background: #eff6ff;
    color: #1d4ed8;
}
.kb-move-node.is-root {
    font-weight: 600;
}
.kb-move-children {
    --kb-move-depth: 0;
}
.kb-move-loading,
.kb-move-empty,
.kb-move-error {
    padding: 16px 12px;
    font-size: 13px;
    color: #64748b;
    text-align: center;
}
.kb-move-error { color: #b91c1c; }

.kb-dots-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    border-radius: 6px;
    padding: 4px 5px;
    cursor: pointer;
    color: #94a3b8;
    opacity: 0;
    transition: opacity .15s, background .1s, color .1s;
    line-height: 1;
}
.kb-item:hover .kb-dots-btn { opacity: 1; }
.kb-dots-btn:hover { background: #e2e8f0; color: #374151; }

/* Кнопки корзины */
.kb-item-actions {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px 10px;
}
.kb-action-restore,
.kb-action-del {
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background .15s;
}
.kb-action-restore { background: #f0fdf4; color: #16a34a; }
.kb-action-restore:hover { background: #dcfce7; }
.kb-action-del { background: #fef2f2; color: #ef4444; }
.kb-action-del:hover { background: #fee2e2; }

/* ── List view ───────────────────────────────────────────────── */
.kb-grid.kb-list {
    grid-template-columns: 1fr;
    gap: 4px;
}
.kb-grid.kb-list .kb-item {
    border-radius: 8px;
}
.kb-grid.kb-list .kb-item-inner {
    flex-direction: row;
    padding: 10px 14px;
    align-items: center;
    gap: 12px;
    text-align: left;
}
.kb-grid.kb-list .kb-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    margin-bottom: 0;
    flex-shrink: 0;
}
.kb-grid.kb-list .kb-item-icon svg { width: 20px; height: 20px; }
.kb-grid.kb-list .kb-item-has-preview .kb-item-icon.kb-thumb {
    width: 64px;
    height: 64px;
}
.kb-grid.kb-list .kb-item-has-preview .kb-item-icon.kb-thumb img {
    object-fit: cover;
}
.kb-grid.kb-list .kb-item-has-preview .kb-shared-badge {
    top: auto;
    right: -4px;
    bottom: -4px;
    width: 18px;
    height: 18px;
}
.kb-grid.kb-list .kb-item-info {
    flex: 1;
    text-align: left;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.kb-grid.kb-list .kb-item-name { text-align: left; }
.kb-grid.kb-list .kb-item-meta { margin-top: 0; }
.kb-grid.kb-list .kb-dots-btn { opacity: 1; top: 50%; transform: translateY(-50%); }

/* ── Пустое состояние ────────────────────────────────────────── */
.kb-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
}
.kb-empty-icon { font-size: 56px; margin-bottom: 14px; line-height: 1; }
.kb-empty-icon-svg { color: #94a3b8; }
.kb-empty-icon-svg svg { display: block; }
.kb-empty-title { font-size: 17px; font-weight: 600; color: #1e293b; margin-bottom: 6px; }
.kb-empty-sub { font-size: 14px; color: #94a3b8; max-width: 320px; }

/* ── Корзина: кнопка очистки ─────────────────────────────────── */
.kb-trash-bar {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
}
.kb-trash-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.kb-trash-clear-btn:hover { background: #fee2e2; }

/* ── Контекстное меню ────────────────────────────────────────── */
.kb-ctx-menu {
    position: fixed;
    min-width: 185px;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.14);
    padding: 6px;
    z-index: 9999;
    display: none;
}
.kb-ctx-item {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13.5px;
    color: #374151;
    text-align: left;
    transition: background .1s;
    white-space: nowrap;
}
.kb-ctx-icon {
    display: inline-flex;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: inherit;
}
.kb-ctx-icon svg {
    width: 16px;
    height: 16px;
}
.kb-ctx-item:hover { background: #f1f5f9; }
.kb-ctx-item.kb-ctx-danger { color: #ef4444; }
.kb-ctx-item.kb-ctx-danger:hover { background: #fef2f2; }
.kb-ctx-sep {
    height: 1px;
    background: #f1f5f9;
    margin: 4px 0;
}

/* ── Viewer (просмотрщик файлов) ─────────────────────────────── */
#kbViewerModal .kb-viewer-card {
    background: #fff;
    border-radius: 18px;
    width: min(92vw, 960px);
    height: min(90dvh, 840px);
    min-height: min(90dvh, 560px);
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0,0,0,.22);
}
.kb-viewer-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: #f8fafc;
}
.kb-viewer-loading {
    color: #94a3b8;
    font-size: 14px;
    margin: auto;
}
.kb-viewer-img {
    max-width: 100%;
    max-height: calc(80dvh - 80px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

/* Единый просмотр изображений: масштаб и прокрутка */
.kb-image-viewer-root {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}
.kb-image-toolbar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 4px 0;
}
.kb-image-tool-btn {
    height: 34px;
    min-width: 38px;
    padding: 0 12px;
    border: 1px solid #d6e0ec;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
    color: #334155;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all .18s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.kb-image-tool-btn:hover:not(:disabled) {
    border-color: #b9cff2;
    color: #1e3a8a;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.16);
}
.kb-image-tool-btn:disabled {
    opacity: .45;
    cursor: default;
}
.kb-image-zoom-label {
    min-width: 52px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
}
.kb-image-tool-sep {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
    margin: 0 4px;
}
.kb-image-tool-hint {
    flex: 1 1 180px;
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
}
.kb-image-stage {
    flex: 1 1 auto;
    width: 100%;
    min-height: 280px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef2f7;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    touch-action: none;
    user-select: none;
}
.kb-image-stage.is-zoomed {
    cursor: grab;
}
.kb-image-stage.is-dragging {
    cursor: grabbing;
}
.kb-image-pan {
    transform-origin: center center;
    will-change: transform;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kb-image-zoomable {
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.12);
    pointer-events: none;
    image-rendering: auto;
}

.kb-photo-nav {
    width: min(100%, 760px);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 0 12px;
}
.kb-photo-nav-btn {
    height: 34px;
    min-width: 140px;
    padding: 0 14px;
    border: 1px solid #d6e0ec;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .18s ease;
}
.kb-photo-nav-btn.prev { margin-right: auto; }
.kb-photo-nav-btn.next { margin-left: auto; }
.kb-photo-nav-btn.rotate-left,
.kb-photo-nav-btn.rotate-right {
    min-width: 42px;
    width: 42px;
    padding: 0;
    font-size: 16px;
    font-weight: 700;
}
.kb-photo-nav-btn.delete-photo {
    min-width: auto;
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #dc2626;
    border-color: #fecaca;
    background: linear-gradient(180deg, #fff 0%, #fef2f2 100%);
}
.kb-photo-nav-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
}
.kb-photo-nav-icon svg {
    width: 16px;
    height: 16px;
}
.kb-photo-nav-btn.delete-photo:hover {
    border-color: #fca5a5;
    color: #b91c1c;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.12);
}
.kb-photo-nav-btn:hover {
    border-color: #b9cff2;
    color: #1e3a8a;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.16);
    transform: translateY(-1px);
}
.kb-photo-nav-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}
.kb-photo-nav-btn.is-disabled,
.kb-photo-nav-btn:disabled {
    opacity: .45;
    cursor: default;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}
.kb-photo-nav-counter {
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef2f7;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.kb-photo-upload {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.kb-photo-upload-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #334155;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.kb-photo-upload-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.kb-photo-upload-btn input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.kb-photo-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.kb-photo-preview-item {
    width: 88px;
    height: 88px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
.kb-photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
body.theme-premium .kb-photo-preview-item {
    border-color: rgba(255,255,255,.12);
    background: rgba(255,255,255,.04);
}
.kb-viewer-iframe {
    width: 100%;
    height: calc(80dvh - 100px);
    border: none;
    border-radius: 8px;
    background: #fff;
}
.kb-viewer-txt {
    width: 100%;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #1e293b;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
    overflow: auto;
    max-height: calc(80dvh - 120px);
}
.kb-viewer-office {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 8px;
}
.kb-viewer-office-icon { font-size: 48px; }
.kb-viewer-office-name { font-weight: 600; font-size: 15px; color: #1e293b; }
.kb-viewer-office-hint { font-size: 12px; color: #94a3b8; margin-bottom: 8px; }
.kb-viewer-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 40px 20px;
}
.kb-vf-icon { font-size: 52px; }
.kb-vf-name { font-weight: 600; font-size: 15px; color: #1e293b; }
.kb-vf-hint { font-size: 13px; color: #94a3b8; margin-bottom: 8px; }
.kb-viewer-audio-wrap {
    padding: 40px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kb-viewer-audio { width: 360px; max-width: 90vw; }
.kb-viewer-video {
    max-width: 100%;
    max-height: calc(80dvh - 80px);
    border-radius: 8px;
    background: #000;
}
.kb-viewer-dl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: #f1f5f9;
    color: #374151;
    border-radius: 8px;
    font-size: 13px;
    text-decoration: none;
    font-weight: 500;
    transition: background .15s;
}
.kb-viewer-dl-btn:hover { background: #e2e8f0; }

/* ── OnlyOffice full-screen viewer/editor ────────────────────── */
#msgOOModal.kboo-overlay {
    z-index: 360;
}
.kboo-overlay {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
}
.kboo-card {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 0;
    overflow: hidden;
}
.kboo-header {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 52px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    gap: 12px;
    flex-shrink: 0;
    background: #fff;
}
.kboo-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1e293b;
}
.kboo-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.kboo-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    color: #fff;
    letter-spacing: .3px;
}
.kboo-badge.view { background: #64748b; }
.kboo-badge.edit { background: #22c55e; }
.kboo-editor {
    flex: 1;
    overflow: hidden;
    background: #f1f5f9;
}

/* Premium theme overrides */
body.theme-premium .kboo-header { background: #0d1626; border-color: rgba(255,255,255,.08); }
body.theme-premium .kboo-title  { color: #e2e8f0; }

/* ── Upload drop zone ────────────────────────────────────────── */
.kb-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 32px 24px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    text-align: center;
    background: #f8fafc;
    user-select: none;
}
.kb-drop-zone:hover,
.kb-drop-zone.drag-over {
    border-color: var(--primary, #3b82f6);
    background: #eff6ff;
}
.kb-drop-icon { color: #94a3b8; }
.kb-drop-title { font-weight: 600; font-size: 14px; color: #475569; }
.kb-drop-hint { font-size: 12px; color: #94a3b8; }

.kb-upload-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 13px;
    color: #374151;
}
.kb-upload-fname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-upload-fsize { color: #94a3b8; font-size: 12px; margin-left: 8px; flex-shrink: 0; }
.kb-upload-more  { font-size: 12px; color: #94a3b8; padding: 4px 10px; }

/* ── Доступ к разделу ────────────────────────────────────────── */
.kb-access-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.kb-access-who { flex: 1; font-size: 14px; font-weight: 500; color: #1e293b; }
.kb-access-all { color: #64748b; }
.kb-access-badges { display: flex; gap: 4px; }

/* ── Premium theme overrides ─────────────────────────────────── */
body.theme-premium .kb-item {
    background: rgba(255,255,255,.04);
    border-color: rgba(255,255,255,.08);
}
body.theme-premium .kb-item:hover {
    border-color: rgba(40,215,198,.28);
    box-shadow: 0 6px 20px rgba(0,0,0,.28);
}
body.theme-premium .kb-item-name { color: #e2e8f0; }
body.theme-premium .kb-empty-title { color: #e2e8f0; }
body.theme-premium .kb-create-menu {
    background: #1a2740;
    border-color: rgba(255,255,255,.1);
}
body.theme-premium .kb-create-item { color: #cbd5e1; }
body.theme-premium .kb-create-item:hover { background: rgba(255,255,255,.07); }
body.theme-premium .kb-view-btn {
    border-color: rgba(255,255,255,.1);
    color: #94a3b8;
}
body.theme-premium .kb-view-btn:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
body.theme-premium .kb-ctx-menu {
    background: #1a2740;
    border-color: rgba(255,255,255,.1);
}
body.theme-premium .kb-ctx-item { color: #cbd5e1; }
body.theme-premium .kb-ctx-item:hover { background: rgba(255,255,255,.07); }
body.theme-premium .kb-section-label,
body.theme-premium .sidebar-group-label { color: rgba(148,163,184,.7); }
body.theme-premium #kbViewerModal .kb-viewer-card {
    background: #111c30;
    border: 1px solid rgba(255,255,255,.1);
}
body.theme-premium .kb-viewer-body { background: #0d1626; }
body.theme-premium .kb-viewer-txt { background: #111c30; border-color: rgba(255,255,255,.1); color: #e2e8f0; }
body.theme-premium .kb-photo-nav-btn {
    background: linear-gradient(180deg, rgba(15, 32, 56, 0.90) 0%, rgba(11, 24, 44, 0.95) 100%);
    border-color: rgba(148, 199, 216, 0.30);
    color: #d7e7ff;
}
body.theme-premium .kb-photo-nav-btn:hover {
    border-color: rgba(93, 194, 255, 0.55);
    color: #f3f9ff;
    box-shadow: 0 6px 18px rgba(53, 145, 233, 0.25);
}
body.theme-premium .kb-photo-nav-counter {
    background: rgba(148, 199, 216, 0.14);
    color: #b8d4ec;
}
body.theme-premium .kb-drop-zone { background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.12); }
body.theme-premium .kb-drop-zone:hover { border-color: rgba(40,215,198,.5); background: rgba(40,215,198,.04); }
body.theme-premium .kb-access-row { background: rgba(255,255,255,.04); }
body.theme-premium .kb-upload-row { background: rgba(255,255,255,.04); color: #cbd5e1; }
body.theme-premium .kb-trash-bar { border-color: rgba(255,255,255,.07); }
body.theme-premium .kb-dots-btn:hover { background: rgba(255,255,255,.1); color: #e2e8f0; }

/* ── Мобильная навигация БЗ (скрыта на десктопе) ─────────────── */
.kb-mobile-nav {
    display: none;
}
.kb-journal-filters-wrap {
    width: 100%;
}
.kb-journal-filters-toggle {
    display: none;
}
@media (min-width: 768px) {
    .kb-journal-filters-wrap > .kb-journal-filter-form {
        display: flex;
    }
}

/* ── Responsive · База знаний ─────────────────────────────────── */
@media (max-width: 767px) {
    body.section-storage {
        touch-action: manipulation;
        -webkit-text-size-adjust: 100%;
    }

    body.section-storage .main-content {
        padding: 8px;
    }

    body.section-storage .content-card {
        padding: 12px;
        border-radius: 12px;
        min-height: calc(100dvh - var(--header-height) - 16px);
    }

    body.section-storage .kb-mobile-nav {
        display: block;
        margin: 0 0 12px;
    }

    body.section-storage .kb-mobile-nav-scroll {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 2px 2px 6px;
        margin: 0 -2px;
    }

    body.section-storage .kb-mobile-nav-scroll::-webkit-scrollbar {
        display: none;
    }

    body.section-storage .kb-mobile-nav-item {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        min-height: 40px;
        padding: 0 14px;
        border-radius: 999px;
        border: 1px solid #dbe3ee;
        background: #fff;
        color: #475569;
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
        white-space: nowrap;
    }

    body.section-storage .kb-mobile-nav-item.is-active {
        background: #eff6ff;
        border-color: #93c5fd;
        color: #1d4ed8;
    }

    body.section-storage .kb-mobile-nav-section {
        max-width: 160px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.section-storage .kb-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 14px;
    }

    body.section-storage .kb-breadcrumb {
        font-size: 13px;
        line-height: 1.35;
        max-width: 100%;
    }

    body.section-storage .kb-header-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 10px;
    }

    body.section-storage .kb-header-toolbar {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
        gap: 10px;
    }

    body.section-storage .kb-journal-filters-wrap {
        order: -1;
    }

    body.section-storage .kb-journal-filters-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 44px;
        padding: 0 14px;
        border: 1px solid #dbe3ee;
        border-radius: 12px;
        background: #f8fafc;
        color: #334155;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        list-style: none;
    }

    body.section-storage .kb-journal-filters-toggle::-webkit-details-marker {
        display: none;
    }

    body.section-storage .kb-journal-filters-toggle::after {
        content: '▾';
        color: #94a3b8;
        transition: transform .15s ease;
    }

    body.section-storage .kb-journal-filters-wrap[open] .kb-journal-filters-toggle::after {
        transform: rotate(180deg);
    }

    body.section-storage .kb-journal-filter-form {
        margin-top: 10px;
    }

    body.section-storage .kb-journal-search,
    body.section-storage .kb-journal-search.kb-journal-date,
    body.section-storage .kb-journal-search.kb-journal-comment,
    body.section-storage .kb-journal-filter-btn {
        width: 100%;
        min-height: 44px;
        font-size: 16px;
    }

    body.section-storage .kb-view-btn {
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
    }

    body.section-storage .kb-header-add-btn,
    body.section-storage .kb-create-wrapper.kb-header-add-btn {
        position: fixed;
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        z-index: 240;
        margin: 0;
    }

    body.section-storage .kb-create-btn,
    body.section-storage .kb-header-toolbar > .btn-add-universal.kb-header-add-btn {
        width: 56px;
        height: 56px;
        min-height: 56px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        box-shadow: 0 10px 28px rgba(37, 99, 235, 0.35);
    }

    body.section-storage .kb-browser {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    body.section-storage .kb-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    body.section-storage .kb-grid.kb-list {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    body.section-storage .kb-item-has-preview .kb-item-icon.kb-thumb {
        height: 96px;
    }

    body.section-storage .kb-item-inner {
        padding: 12px 10px 10px;
    }

    body.section-storage .kb-item-name {
        font-size: 13px;
    }

    body.section-storage .kb-dots-btn {
        opacity: 1;
        width: 40px;
        height: 40px;
        top: 8px;
        right: 8px;
        transform: none;
    }

    body.section-storage .kb-grid.kb-list .kb-dots-btn {
        top: 50%;
        transform: translateY(-50%);
    }

    body.section-storage .kb-transfer-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    body.section-storage .kb-transfer-banner-actions {
        flex-direction: column;
    }

    body.section-storage .kb-transfer-banner-actions .btn-modal-save,
    body.section-storage .kb-transfer-banner-actions .btn-modal-cancel {
        width: 100%;
        min-height: 44px;
    }

    body.section-storage .table-wrapper:has(.kb-journal-table) {
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    body.section-storage .kb-journal-table {
        min-width: 0;
        width: 100%;
        border: 0;
    }

    body.section-storage .kb-journal-table thead {
        display: none;
    }

    body.section-storage .kb-journal-table tbody tr {
        display: block;
        margin-bottom: 10px;
        padding: 12px;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    }

    body.section-storage .kb-journal-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        min-width: 0;
        padding: 7px 0;
        border: 0;
        font-size: 14px;
    }

    body.section-storage .kb-journal-table tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: .02em;
        color: #64748b;
        text-transform: uppercase;
    }

    body.section-storage .kb-journal-table tbody td[data-label="Фото"] {
        justify-content: flex-start;
    }

    body.section-storage .kb-journal-table tbody td[data-label="Фото"]::before {
        margin-right: auto;
    }

    body.section-storage .kb-journal-table .actions-cell {
        justify-content: flex-end;
        border-top: 1px solid #f1f5f9;
        margin-top: 6px;
        padding-top: 10px;
    }

    body.section-storage .kb-journal-table .actions-cell::before {
        content: 'Действия';
    }

    body.section-storage .kb-journal-table .actions-cell .btn-icon {
        width: 44px;
        height: 44px;
    }

    body.section-storage .kb-table-photo {
        width: 52px;
        height: 52px;
    }

    body.section-storage .kb-photo-upload {
        flex-direction: column;
    }

    body.section-storage .kb-photo-upload-btn {
        width: 100%;
        min-height: 48px;
        justify-content: center;
        font-size: 15px;
    }

    body.section-storage .kb-photo-preview-item {
        width: 72px;
        height: 72px;
    }

    body.section-storage .kb-create-menu {
        right: 0;
        left: auto;
        bottom: calc(100% + 10px);
        top: auto;
        min-width: 220px;
    }

    body.section-storage .kb-ctx-menu.kb-ctx-mobile {
        min-width: 0;
        max-height: min(70dvh, 520px);
        border-radius: 16px 16px 12px 12px;
        padding: 8px;
    }

    body.section-storage .kb-ctx-menu.kb-ctx-mobile .kb-ctx-item {
        min-height: 48px;
        font-size: 15px;
        white-space: normal;
    }

    body.section-storage #kbViewerModal .kb-viewer-card {
        width: 100vw;
        height: 96dvh;
        min-height: 96dvh;
        max-height: 96dvh;
        border-radius: 18px 18px 0 0;
        align-self: flex-end;
    }

    body.section-storage .kb-viewer-iframe {
        height: calc(80dvh - 80px);
    }

    body.section-storage .kb-image-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    body.section-storage .kb-image-tool-btn {
        min-width: 44px;
        min-height: 44px;
    }

    body.section-storage .kb-image-tool-hint {
        display: none;
    }

    body.section-storage .kb-image-stage {
        min-height: 220px;
    }

    body.section-storage .kb-photo-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    body.section-storage .kb-photo-nav-btn.prev,
    body.section-storage .kb-photo-nav-btn.next,
    body.section-storage .kb-photo-nav-btn.delete-photo,
    body.section-storage .kb-photo-nav-counter {
        width: 100%;
        margin: 0;
        min-height: 44px;
        text-align: center;
    }
}

@media (max-width: 420px) {
    body.section-storage .kb-mobile-nav-section {
        max-width: 120px;
    }

    body.section-storage .kb-grid:not(.kb-list) {
        grid-template-columns: 1fr;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   ГЛАВНАЯ СТРАНИЦА (home.php)
   ═══════════════════════════════════════════════════════════════════ */

.home-welcome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f1f5f9;
}
.home-title {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}
.home-sub {
    font-size: 14px;
    color: #94a3b8;
    margin: 0;
}
.home-welcome-date {
    font-size: 13px;
    color: #94a3b8;
    background: #f8fafc;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
}

/* Сетка модулей */
.home-modules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 36px;
}
.home-module {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px 16px 20px;
    border-radius: 16px;
    border: 1px solid #e8edf4;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s, border-color .15s;
    background: #fff;
    text-align: center;
}
.home-module:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    border-color: transparent;
}
.home-mod-icon {
    width: 60px; height: 60px;
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s;
}
.home-module:hover .home-mod-icon { transform: scale(1.08); }
.home-mod-label { font-size: 14px; font-weight: 700; color: #1e293b; }
.home-mod-desc  { font-size: 12px; color: #94a3b8; }

/* Цвета карточек */
.home-mod-messenger .home-mod-icon { background: #eff6ff; color: #3b82f6; }
.home-mod-messenger:hover { box-shadow: 0 8px 24px rgba(59,130,246,.15); }
.home-mod-ai .home-mod-icon { background: #f5f3ff; color: #7c3aed; }
.home-mod-ai:hover { box-shadow: 0 8px 24px rgba(124,58,237,.15); }
.home-mod-storage .home-mod-icon { background: #f0fdf4; color: #16a34a; }
.home-mod-storage:hover { box-shadow: 0 8px 24px rgba(22,163,74,.15); }
.home-mod-settings .home-mod-icon { background: #fff7ed; color: #ea580c; }
.home-mod-settings:hover { box-shadow: 0 8px 24px rgba(234,88,12,.15); }
.home-mod-admin .home-mod-icon { background: #fef2f2; color: #ef4444; }
.home-mod-admin:hover { box-shadow: 0 8px 24px rgba(239,68,68,.15); }

/* Недавние файлы */
.home-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
}
.home-see-all { font-size: 13px; color: var(--primary,#3b82f6); text-decoration: none; font-weight: 400; }
.home-see-all:hover { text-decoration: underline; }
.home-recent-list { display: flex; flex-direction: column; gap: 4px; }
.home-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #f8fafc;
    text-decoration: none;
    color: inherit;
    transition: background .12s;
    font-size: 13.5px;
}
.home-recent-item:hover { background: #f1f5f9; }
.home-recent-ico {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.home-recent-ico svg { width: 20px; height: 20px; }
.home-recent-ico.kb-icon-folder { background: #fffbeb; color: #f59e0b; }
.home-recent-ico.kb-icon-img    { background: #eff6ff; color: #3b82f6; }
.home-recent-ico.kb-icon-pdf    { background: #fef2f2; color: #ef4444; }
.home-recent-ico.kb-icon-word   { background: #eff6ff; color: #2563eb; }
.home-recent-ico.kb-icon-excel  { background: #f0fdf4; color: #16a34a; }
.home-recent-ico.kb-icon-ppt    { background: #fff7ed; color: #ea580c; }
.home-recent-ico.kb-icon-txt    { background: #f8fafc; color: #64748b; }
.home-recent-ico.kb-icon-zip    { background: #fefce8; color: #ca8a04; }
.home-recent-ico.kb-icon-video  { background: #f5f3ff; color: #7c3aed; }
.home-recent-ico.kb-icon-audio  { background: #fdf4ff; color: #a21caf; }
.home-recent-ico.kb-icon-file   { background: #f8fafc; color: #94a3b8; }
.home-recent-name { flex: 1; font-weight: 500; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-recent-meta { font-size: 12px; color: #94a3b8; flex-shrink: 0; }

/* Premium theme */
body.theme-premium .home-welcome   { border-color: rgba(255,255,255,.07); }
body.theme-premium .home-title     { color: #e2e8f0; }
body.theme-premium .home-module    { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.08); }
body.theme-premium .home-module:hover { border-color: transparent; }
body.theme-premium .home-mod-label { color: #e2e8f0; }
body.theme-premium .home-welcome-date { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); color: #94a3b8; }
body.theme-premium .home-recent-item { background: rgba(255,255,255,.04); }
body.theme-premium .home-recent-item:hover { background: rgba(255,255,255,.07); }
body.theme-premium .home-recent-name { color: #e2e8f0; }
body.theme-premium .home-section-head { color: #e2e8f0; }

@media (max-width: 767px) {
    .home-modules { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .home-title { font-size: 18px; }
    .home-welcome { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ═══════════════════════════════════════════════════════════════════
   ФАЙЛОВЫЙ МЕНЕДЖЕР — дополнительные фиксы
   ═══════════════════════════════════════════════════════════════════ */

/* Жёсткое ограничение SVG внутри иконки (защита от сброса стилей) */
.kb-item-icon svg {
    width: 28px !important;
    height: 28px !important;
    flex-shrink: 0;
}
.kb-item-icon:not(.kb-thumb) img {
    width: 28px !important;
    height: 28px !important;
    flex-shrink: 0;
}

/* drop-zone теперь div, не label */
.kb-drop-zone { cursor: pointer; }

/* Подсветка активного пункта секции в файловом менеджере */
.kb-grid .kb-item.kb-folder:focus-within,
.kb-grid .kb-item.kb-file:focus-within {
    outline: 2px solid var(--primary, #3b82f6);
    outline-offset: 2px;
}


/* Логотип в шапке как ссылка на главную */
.top-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 4px;
}
@media (max-width: 767px) {
    .top-logo-link { display: none; }
}

/* ── Мессенджер · левая панель ─────────────────────────────────── */
body.section-messenger {
    --sidebar-width: 320px;
}

body.section-messenger .sidebar {
    overflow: hidden;
}

body.section-messenger .sidebar-menu {
    display: none;
}

body.section-messenger .main-content.msg-main {
    padding: 0;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.msg-sidebar {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.msg-sidebar-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 14px 10px;
    flex-shrink: 0;
}

.msg-search-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.msg-search-icon {
    position: absolute;
    left: 12px;
    color: #94a3b8;
    pointer-events: none;
}

.msg-search-input {
    width: 100%;
    height: 40px;
    padding: 0 36px 0 38px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.msg-search-input:focus {
    border-color: var(--section-color);
    box-shadow: 0 0 0 3px var(--section-soft);
}

.msg-search-input::-webkit-search-cancel-button {
    display: none;
}

.msg-search-clear {
    position: absolute;
    right: 6px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-search-clear:hover {
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-create-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--panel-bg);
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.12s ease;
}

.msg-create-btn:hover {
    border-color: var(--section-color);
    color: var(--section-color);
    background: var(--section-soft);
}

.msg-create-btn:active {
    transform: scale(0.94);
}

.msg-editor-wrap {
    position: relative;
    flex-shrink: 0;
}

.msg-editor-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--panel-bg);
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.msg-editor-btn:hover,
.msg-editor-btn.is-open {
    border-color: var(--section-color);
    color: var(--section-color);
    background: var(--section-soft);
}

.msg-editor-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 240px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--panel-bg);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    z-index: 30;
}

.msg-editor-panel-head {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 10px;
}

.msg-editor-field {
    display: block;
    margin-bottom: 10px;
}

.msg-editor-label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.msg-editor-select {
    width: 100%;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 13px;
}

.msg-editor-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 12px;
    cursor: pointer;
}

.msg-editor-check input {
    accent-color: var(--section-color);
}

.msg-editor-action {
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: var(--section-soft);
    color: var(--section-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.msg-editor-action:hover {
    background: rgba(217, 119, 6, 0.22);
}

.msg-editor-action-primary {
    background: var(--section-color);
    color: #fff;
}

.msg-editor-action-primary:hover {
    background: #b45309;
}

.msg-chat-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.msg-chat-status-icon {
    display: inline-flex;
    align-items: center;
    color: #94a3b8;
}

.msg-chat-row.is-pinned .msg-chat-status-icon:first-child,
.msg-chat-row.is-muted .msg-chat-status-icon {
    color: var(--section-color);
}

.msg-chat-menu-btn {
    flex-shrink: 0;
    width: 34px;
    margin: 8px 8px 8px 0;
    align-self: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.msg-chat-menu-btn:hover,
.msg-chat-menu-btn.is-open {
    background: var(--section-soft);
    color: var(--section-color);
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.12);
}

.msg-chat-menu {
    position: fixed;
    z-index: 120;
    width: 220px;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--panel-bg);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}

.msg-chat-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.msg-chat-menu-item svg {
    flex-shrink: 0;
    color: #64748b;
}

.msg-chat-menu-item:hover {
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-chat-menu-item:hover svg {
    color: var(--section-color);
}

.msg-chat-menu-item-danger {
    color: #dc2626;
}

.msg-chat-menu-item-danger svg {
    color: #dc2626;
}

.msg-chat-menu-item-danger:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
}

.msg-chat-menu-divider {
    height: 1px;
    margin: 4px 6px;
    background: var(--border-color);
}

.msg-chat-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.msg-modal-card {
    max-width: 480px;
}

.msg-modal-form {
    padding-top: 12px;
}

.msg-modal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.msg-modal-tab {
    flex: 1;
    min-height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--panel-bg);
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.msg-modal-tab.active {
    border-color: var(--section-color);
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-modal-pane {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-modal-pane[hidden] {
    display: none !important;
}

.msg-create-group-avatar-wrap {
    display: flex;
    justify-content: center;
    padding: 4px 0 8px;
}

.msg-modal-pane .modal-row {
    margin-bottom: 0;
}

.msg-modal-pane .modal-row + .modal-row {
    margin-top: 4px;
}

.msg-modal-pane .modal-row label {
    margin-bottom: 6px;
}

.msg-modal-pane .modal-row .msg-contact-search-wrap {
    margin-bottom: 8px;
}

.msg-modal-pane .msg-selected-members:not(:empty) {
    margin-bottom: 8px;
}

.msg-modal-pane .modal-footer {
    margin-top: 8px;
    padding-top: 0;
    border-top: none;
}

.msg-contact-search-wrap {
    margin-bottom: 0;
}

.msg-contact-search-wrap--icon {
    position: relative;
}

.msg-contact-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    color: #94a3b8;
    pointer-events: none;
}

.msg-contact-search-wrap--icon .msg-contact-search {
    padding-left: 36px;
}

.msg-contact-search {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.msg-contact-search:focus {
    border-color: var(--section-color);
    box-shadow: 0 0 0 3px var(--section-soft);
}

.msg-contact-list {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--panel-bg);
}

.msg-contact-list-compact {
    max-height: 160px;
}

.msg-contact-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: inherit;
    transition: background 0.12s;
}

.msg-contact-item:last-child {
    border-bottom: none;
}

.msg-contact-item:hover:not(:disabled) {
    background: var(--section-soft);
}

.msg-contact-item:disabled {
    opacity: 0.5;
    cursor: default;
}

.msg-contact-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fbbf24, var(--section-color, #d97706));
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.msg-contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-contact-initials {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.msg-contact-info {
    flex: 1;
    min-width: 0;
}

.msg-contact-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-contact-login {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 1px;
}

.msg-contact-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.msg-contact-status.is-online {
    background: #22c55e;
}

.msg-contact-status.is-offline {
    background: #cbd5e1;
}

.msg-contact-empty,
.msg-selected-empty {
    padding: 24px 12px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.msg-selected-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 0;
}

.msg-selected-members:not(:empty) {
    margin-bottom: 2px;
}

.msg-member-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--section-soft);
    color: var(--section-color);
    font-size: 12px;
    font-weight: 600;
}

.msg-member-chip-remove {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.7;
}

.msg-member-chip-remove:hover {
    opacity: 1;
}

body.theme-dark .msg-contact-search {
    background: #111827;
}

.msg-filter-tabs {
    display: flex;
    gap: 6px;
    padding: 0 14px 12px;
    flex-shrink: 0;
}

.msg-filter-tab {
    flex: 1;
    min-height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--panel-bg);
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.msg-filter-tab:hover {
    border-color: var(--section-color);
    color: var(--section-color);
}

.msg-filter-tab.active {
    border-color: var(--section-color);
    color: var(--section-color);
    background: var(--section-soft);
    box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.15);
}

.msg-chat-list-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}

.msg-chat-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.msg-chat-row {
    display: flex;
    align-items: stretch;
    position: relative;
    border-left: 3px solid transparent;
    transition: background 0.15s;
}

.msg-chat-row:hover {
    background: rgba(0, 0, 0, 0.03);
}

.msg-chat-row.active {
    background: var(--section-soft);
    border-left-color: var(--section-color);
}

.msg-chat-row.is-pinned {
    background: rgba(217, 119, 6, 0.04);
}

.msg-chat-item {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 6px 12px 16px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.msg-chat-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fbbf24, #d97706);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-chat-avatar-text {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.msg-chat-avatar.is-online::after,
.msg-chat-avatar.is-offline::after {
    content: '';
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid var(--panel-bg);
}

.msg-chat-avatar.is-online::after {
    background: #22c55e;
}

.msg-chat-avatar.is-offline::after {
    background: #94a3b8;
}

.msg-chat-body {
    flex: 1;
    min-width: 0;
}

.msg-chat-top,
.msg-chat-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.msg-chat-top {
    margin-bottom: 3px;
}

.msg-chat-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-chat-time {
    font-size: 12px;
    color: #94a3b8;
    flex-shrink: 0;
}

.msg-chat-preview {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.msg-chat-badge {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--section-color);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.msg-chat-row[hidden] {
    display: none !important;
}

.msg-chat-empty[hidden] {
    display: none !important;
}

.msg-chat-empty:not([hidden]) {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: #94a3b8;
    text-align: center;
    pointer-events: none;
}

.msg-chat-empty p {
    font-size: 14px;
}

.msg-chat-area {
    height: 100%;
    background: var(--panel-bg);
    border-left: 1px solid var(--border-color);
    min-width: 0;
    overflow: hidden;
}

.msg-panel-layout {
    --msg-info-sidebar-width: clamp(260px, 30vw, 320px);
    display: flex;
    height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.msg-panel-layout .msg-panel {
    flex: 1 1 auto;
    min-width: 0;
}

.msg-info-sidebar {
    flex: 0 0 auto;
    max-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border-left: 1px solid transparent;
    box-shadow: none;
    transition: max-width 0.32s cubic-bezier(0.32, 0.72, 0, 1), border-color 0.28s ease, box-shadow 0.28s ease;
}

.msg-panel-layout.is-info-open .msg-info-sidebar {
    max-width: var(--msg-info-sidebar-width);
    border-left-color: var(--border-color);
    box-shadow: -10px 0 28px rgba(15, 23, 42, 0.06);
}

.msg-info-sidebar-shell {
    width: var(--msg-info-sidebar-width);
    min-width: var(--msg-info-sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.msg-panel-layout.is-info-open .msg-info-sidebar-shell {
    animation: msgSidebarShellIn 0.28s cubic-bezier(0.32, 0.72, 0, 1) 0.06s both;
}

@keyframes msgSidebarShellIn {
    from {
        opacity: 0.55;
        transform: translateX(12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
.msg-info-sidebar-header,
.msg-info-sidebar-body {
    opacity: 1;
    transform: none;
    transition: none;
}

.msg-info-sidebar-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 14px 20px;
}

.msg-info-sidebar-header {
    display: flex;
    justify-content: flex-end;
    padding: 10px 12px 0;
    flex-shrink: 0;
}
.msg-info-sidebar-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.msg-info-sidebar-close:hover {
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-info-sidebar-loading,
.msg-info-sidebar-empty,
.msg-info-empty {
    padding: 16px 0;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.msg-info-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 4px 0 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 14px;
}

.msg-info-avatar-img,
.msg-info-avatar-text {
    width: 88px;
    height: 88px;
    border-radius: 14px;
    object-fit: cover;
    margin-bottom: 10px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
}

.msg-info-avatar-text {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--section-soft);
    color: var(--section-color);
    font-size: 36px;
    font-weight: 600;
}

.msg-info-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.2;
}

.msg-info-subtitle {
    margin-top: 6px;
    font-size: 14px;
    color: #64748b;
}

.msg-info-meta {
    margin-top: 4px;
    font-size: 13px;
    color: #94a3b8;
}

.msg-info-section {
    margin-bottom: 16px;
}

.msg-info-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.msg-info-section-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.msg-info-show-all {
    border: none;
    background: none;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--section-color);
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.msg-info-show-all:hover {
    opacity: 0.75;
    text-decoration: underline;
}

.msg-info-media-all {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.msg-info-media-all-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.msg-info-media-back {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: var(--section-soft);
    color: var(--section-color);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.msg-info-media-back:hover {
    background: color-mix(in srgb, var(--section-soft) 70%, var(--section-color));
}

.msg-info-media-all-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.msg-info-media-all-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
}

.msg-info-media-grid-all {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.msg-info-media-grid-all .msg-info-media-item {
    border-radius: 8px;
}

.msg-info-section-head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.msg-info-section-count {
    font-size: 12px;
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 999px;
    padding: 2px 8px;
}

.msg-info-media-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
}

.msg-info-media-item {
    position: relative;
    aspect-ratio: 1;
    border: none;
    border-radius: 4px;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    background: rgba(148, 163, 184, 0.12);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.msg-info-media-item:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
    z-index: 1;
}

.msg-info-media-item img,
.msg-info-media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.msg-info-media-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.28);
    color: #fff;
    font-size: 11px;
}

.msg-info-files-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.msg-info-file-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--panel-bg);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.msg-info-file-item:hover {
    background: var(--section-soft);
    border-color: color-mix(in srgb, var(--section-color) 25%, var(--border-color));
}

.msg-info-file-icon {
    flex-shrink: 0;
    font-size: 18px;
}

.msg-info-file-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg-info-file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-info-file-time,
.msg-info-file-datetime {
    font-size: 11px;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
}

.msg-info-file-datetime {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.msg-info-files-list-all .msg-info-file-item {
    padding: 12px 14px;
}

.msg-info-files-list-all .msg-info-file-datetime {
    font-size: 12px;
    color: var(--section-color);
    font-weight: 600;
}

.msg-info-files-all-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
}

.msg-info-files-all {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.msg-info-settings-section {
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    margin-top: 4px;
}

.msg-info-settings-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 4px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}

.msg-info-settings-row:hover {
    background: var(--section-soft);
}

.msg-info-settings-row-danger {
    color: #dc2626;
}

.msg-info-settings-row-danger:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
}

.msg-info-settings-row.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.msg-info-settings-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.msg-info-settings-row-danger .msg-info-settings-icon {
    color: #dc2626;
}

.msg-info-settings-label {
    min-width: 0;
    flex: 1;
}

.msg-info-settings-badge {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--section-soft);
}

.msg-info-settings-row.is-muted-active .msg-info-settings-badge {
    color: var(--section-color);
}

.msg-info-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.msg-info-action-btn {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--panel-bg);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.msg-info-action-btn:hover {
    background: var(--section-soft);
    border-color: color-mix(in srgb, var(--section-color) 25%, var(--border-color));
    color: var(--section-color);
}

.msg-info-action-btn-danger {
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.18);
}

.msg-info-action-btn-danger:hover {
    background: rgba(220, 38, 38, 0.08);
    border-color: rgba(220, 38, 38, 0.28);
    color: #dc2626;
}

.msg-panel-compose-btn.is-active {
    color: var(--section-color);
    background: var(--section-soft);
}

.msg-panel-action-btn.is-open {
    background: var(--section-soft);
    color: var(--section-color);
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.12);
}

.msg-chat-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #94a3b8;
    padding: 24px;
    text-align: center;
}

.msg-chat-placeholder p {
    font-size: 15px;
}

body.theme-dark .msg-chat-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

body.theme-dark .msg-search-input,
body.theme-dark .msg-create-btn {
    background: #111827;
}

/* Мобильная адаптация мессенджера — см. блок в конце файла */

/* ── Мессенджер · панель переписки ─────────────────────────────── */
.msg-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    background: var(--panel-bg);
}

.msg-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.msg-panel-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.msg-panel-back-btn {
    display: none;
}

.msg-panel-avatar {
    width: 46px;
    height: 46px;
}

.msg-panel-avatar.is-editable {
    cursor: pointer;
}

.msg-panel-avatar.is-editable:hover {
    opacity: 0.85;
}

.msg-group-avatar-row {
    margin-bottom: 4px;
}

.msg-group-avatar-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.msg-group-avatar-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.msg-group-avatar-btn {
    position: relative;
    width: 88px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.msg-group-avatar-btn:hover {
    transform: scale(1.03);
}

.msg-group-avatar-btn:active {
    transform: scale(0.98);
}

.msg-group-avatar-inner {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #fbbf24, var(--section-color, #d97706));
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.2);
    border: 3px solid var(--panel-bg);
    outline: 2px solid var(--border-color);
    transition: outline-color 0.15s, box-shadow 0.15s;
}

.msg-group-avatar-btn:hover .msg-group-avatar-inner {
    outline-color: var(--section-color);
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.28);
}

.msg-group-avatar-btn.has-image .msg-group-avatar-inner {
    background: var(--section-soft);
    outline-color: var(--section-color);
}

.msg-group-avatar-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.msg-group-avatar-img[hidden] {
    display: none !important;
}

.msg-group-avatar-text {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    color: #fff;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    user-select: none;
}

.msg-group-avatar-text[hidden] {
    display: none !important;
}

.msg-group-avatar-badge {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--section-color);
    color: #fff;
    border: 2px solid var(--panel-bg);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
    pointer-events: none;
}

.msg-group-avatar-caption {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
}

.msg-group-avatar-hint {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.4;
}

.msg-group-avatar-input {
    display: none;
}

.msg-panel-header-info {
    min-width: 0;
}

.msg-panel-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-panel-subtitle {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-panel-status {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.msg-panel-status.is-online {
    color: #16a34a;
}

.msg-panel-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--section-color);
    margin-top: 2px;
    min-height: 16px;
}

.msg-panel-typing[hidden] {
    display: none !important;
}

.msg-panel-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 12px;
}

.msg-panel-typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.35;
    animation: msgTypingDot 1.2s ease-in-out infinite;
}

.msg-panel-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.msg-panel-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes msgTypingDot {
    0%, 60%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.msg-panel-header.is-typing .msg-panel-status,
.msg-panel-header.is-typing .msg-panel-subtitle {
    display: none;
}

.msg-panel-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.msg-panel-action-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--panel-bg);
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.msg-panel-action-btn:hover {
    border-color: var(--section-color);
    color: var(--section-color);
    background: var(--section-soft);
}

.msg-panel-body {
    position: relative;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.65), rgba(255, 255, 255, 0));
}

.msg-panel-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    overflow-x: hidden;
}

.msg-panel-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #94a3b8;
    font-size: 14px;
    text-align: center;
}

.msg-panel-empty[hidden] {
    display: none !important;
}

.msg-panel-date {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0 14px;
}

.msg-panel-date span {
    padding: 4px 14px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
}

.msg-bubble-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 78%;
}

.msg-bubble-row.msg-bubble-out {
    margin-left: auto;
    flex-direction: row-reverse;
}

.msg-bubble-row.msg-bubble-in {
    margin-right: auto;
}

.msg-bubble-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.msg-bubble-wrap {
    position: relative;
    min-width: 0;
    flex: 1 1 auto;
    max-width: 100%;
}

.msg-bubble-heart-btn {
    flex-shrink: 0;
    align-self: flex-end;
    width: 28px;
    height: 28px;
    margin-bottom: 6px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.15s ease, transform 0.12s ease;
}

.msg-bubble-heart-btn .msg-heart-icon {
    width: 18px;
    height: 18px;
    display: block;
    pointer-events: none;
}

.msg-bubble-heart-btn.is-active,
.msg-bubble-heart-btn.has-reactions {
    color: var(--section-color);
}

.msg-bubble-heart-btn.is-active .msg-heart-icon {
    fill: var(--section-color);
    stroke: var(--section-color);
}

.msg-bubble-heart-btn:active {
    transform: scale(1.12);
}

.msg-bubble-quick-reactions,
.msg-bubble-reactions,
.msg-reaction-picker {
    display: none !important;
}

.msg-bubble-quick-reactions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: auto;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    border-radius: 999px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px) scale(0.94);
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 3;
    max-width: min(240px, calc(100vw - 40px));
}

.msg-bubble-quick-reactions::after {
    content: '';
    position: absolute;
    left: -6px;
    right: -6px;
    top: 100%;
    height: 12px;
}

.msg-bubble-out .msg-bubble-quick-reactions {
    left: auto;
    right: 0;
}

.msg-bubble-quick-reactions.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.msg-quick-reaction {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.msg-quick-reaction:hover {
    background: var(--section-soft);
    transform: scale(1.08);
}

.msg-quick-reaction-emoji {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
    pointer-events: none;
}

@media (hover: none) {
    .msg-bubble-quick-reactions {
        opacity: 0;
        pointer-events: none;
        transform: translateY(6px) scale(0.94);
    }

    .msg-bubble-quick-reactions.is-open {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0) scale(1);
    }

    .msg-bubble-actions {
        opacity: 0;
        pointer-events: none;
    }

    .msg-bubble-row:focus-within .msg-bubble-actions {
        opacity: 1;
        pointer-events: auto;
    }
}

.msg-bubble-sender {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
    padding-left: 4px;
}

.msg-bubble {
    border-radius: 14px;
    padding: 10px 12px 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.msg-bubble-in .msg-bubble {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.msg-bubble-out .msg-bubble {
    background: rgba(217, 119, 6, 0.14);
    border: 1px solid rgba(217, 119, 6, 0.18);
    border-bottom-right-radius: 4px;
}

.msg-bubble-text {
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-color);
    word-break: break-word;
}

.msg-emoji-inline {
    width: 1.125em;
    height: 1.125em;
    vertical-align: -0.12em;
    display: inline-block;
    margin: 0 0.05em;
    object-fit: contain;
}

.msg-compose-emoji {
    width: 1.125em;
    height: 1.125em;
    vertical-align: -0.12em;
    display: inline-block;
    margin: 0 0.05em;
    object-fit: contain;
    pointer-events: none;
}

.msg-compose-emoji-icon {
    display: block;
    flex-shrink: 0;
}

.msg-bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
}

.msg-bubble-time {
    font-size: 11px;
    color: #94a3b8;
}

.msg-bubble-read {
    display: inline-flex;
    color: #94a3b8;
}

.msg-bubble-read.is-read {
    color: var(--section-color);
}

.msg-panel-compose {
    flex-shrink: 0;
    padding: 14px 16px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--panel-bg);
}

.msg-panel-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.msg-compose-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    padding-bottom: 3px;
}

.msg-compose-left-tools {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.msg-panel-input-wrap {
    flex: 1;
    min-width: 0;
}

.msg-panel-input-box {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    min-width: 0;
}

.msg-panel-attach-btn::before {
    display: none;
    content: '+';
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
    color: #64748b;
}

.msg-panel-emoji-btn {
    flex-shrink: 0;
}

.msg-panel-autodelete-btn {
    flex-shrink: 0;
}

.msg-panel-compose-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.msg-compose-tool-icon {
    display: block;
    flex-shrink: 0;
}

.msg-panel-compose-btn:hover {
    color: var(--section-color);
    background: var(--section-soft);
}

.msg-panel-compose-btn:active {
    transform: scale(0.94);
}

.msg-panel-compose-btn.is-active {
    color: var(--section-color);
    background: color-mix(in srgb, var(--section-color) 14%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--section-color) 22%, transparent);
}

.msg-panel-input {
    width: 100%;
    min-height: 42px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.msg-panel-input:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

.msg-panel-input:focus {
    border-color: color-mix(in srgb, var(--section-color) 55%, var(--border-color));
    box-shadow: 0 0 0 3px var(--section-soft);
}

.msg-panel-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: var(--section-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.msg-panel-send-btn:hover {
    background: #b45309;
}

.msg-panel-send-btn.is-edit-mode {
    background: var(--section-color);
}

.msg-panel-send-btn.is-edit-mode:hover {
    background: #b45309;
}

.msg-panel-voice-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-color);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.msg-panel-voice-btn:hover:not(:disabled) {
    color: var(--section-color);
    background: var(--section-soft);
    border-color: color-mix(in srgb, var(--section-color) 35%, var(--border-color));
}

.msg-panel-voice-btn:active:not(:disabled) {
    transform: scale(0.94);
}

.msg-panel-voice-btn.is-recording {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.35);
}

.msg-panel-voice-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.msg-panel-input-wrap.is-recording .msg-panel-input {
    display: none;
}

.msg-voice-recording {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.06);
    color: var(--text-color);
}

.msg-voice-recording[hidden] {
    display: none !important;
}

.msg-voice-recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    flex-shrink: 0;
    animation: msg-voice-pulse 1.2s ease-in-out infinite;
}

@keyframes msg-voice-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.85); }
}

.msg-voice-recording-label {
    font-size: 14px;
    color: #64748b;
    white-space: nowrap;
}

.msg-voice-recording-time {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #ef4444;
    min-width: 36px;
}

.msg-voice-recording-stop {
    margin-left: auto;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.12s ease;
}

.msg-voice-recording-stop:hover {
    background: #dc2626;
}

.msg-voice-recording-stop:active {
    transform: scale(0.94);
}

.msg-bubble-voice {
    margin-top: 2px;
}

.msg-bubble-voice-player {
    display: block;
    width: min(260px, 100%);
    height: 36px;
}

.msg-panel-voice-btn.is-unavailable {
    opacity: 0.55;
}

.msg-voice-secure-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.08);
    color: #92400e;
    font-size: 12px;
    line-height: 1.45;
}

.msg-voice-secure-hint[hidden] {
    display: none !important;
}

.msg-voice-secure-hint-icon {
    flex-shrink: 0;
    margin-top: 1px;
    color: #d97706;
}

.msg-voice-secure-hint-text {
    word-break: break-word;
}

body.theme-dark .msg-voice-secure-hint {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.12);
}

body.theme-dark .msg-panel-voice-btn {
    background: #111827;
}

body.theme-dark .msg-voice-recording {
    background: rgba(239, 68, 68, 0.12);
}

body.theme-dark .msg-panel-body {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.5), rgba(31, 41, 55, 0));
}

body.theme-dark .msg-panel-input {
    background: #111827;
}

body.theme-dark .msg-bubble-in .msg-bubble {
    background: #1f2937;
}

/* ── Мессенджер · уведомления ──────────────────────────────────── */
.nav-item {
    position: relative;
}

.nav-msg-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    flex-shrink: 0;
}

.nav-msg-badge[hidden] {
    display: none !important;
}

body.section-messenger .nav-item.active .nav-msg-badge {
    background: var(--section-color);
}

.msg-chat-row.has-unread .msg-chat-name {
    font-weight: 700;
}

.msg-chat-row.has-unread .msg-chat-preview {
    color: var(--text-color);
    font-weight: 500;
}

.msg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.msg-lightbox[hidden] {
    display: none !important;
}

body.msg-lightbox-open {
    overflow: hidden;
}

.msg-lightbox-backdrop {
    position: absolute;
    inset: 0;
    border: none;
    background: rgba(15, 23, 42, 0.72);
    cursor: zoom-out;
}

.msg-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
}

.msg-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.msg-lightbox-stage {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: min(960px, 92vw);
    max-height: 88vh;
    min-height: 0;
    overflow: hidden;
    padding: 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.msg-lightbox-caption {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    width: 100%;
    text-align: center;
}

.msg-lightbox-caption[hidden] {
    display: none !important;
}

.msg-lightbox-caption-kind {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
}

.msg-lightbox-caption-datetime {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: #334155;
    font-variant-numeric: tabular-nums;
}

.msg-lightbox-img {
    display: block;
    max-width: 100%;
    max-height: calc(88vh - 120px);
    width: auto;
    height: auto;
    object-fit: contain;
    flex-shrink: 1;
    min-height: 0;
    image-rendering: auto;
}

.msg-bubble-row:hover .msg-bubble-actions,
.msg-bubble-row:focus-within .msg-bubble-actions {
    opacity: 1;
    pointer-events: auto;
}

.msg-bubble-actions {
    position: absolute;
    top: -10px;
    right: 0;
    display: flex;
    opacity: 0;
    pointer-events: none;
    align-items: center;
    gap: 4px;
    padding: 2px;
    border-radius: 8px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    z-index: 2;
    transition: opacity 0.15s;
}

.msg-bubble-out .msg-bubble-actions {
    right: auto;
    left: 0;
}

.msg-bubble-action {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-bubble-action:hover {
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-bubble-reply {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    border-left: 3px solid var(--section-color);
    background: rgba(148, 163, 184, 0.12);
    border-radius: 8px;
    padding: 6px 8px;
    margin-bottom: 6px;
    cursor: pointer;
}

.msg-bubble-out .msg-bubble-reply {
    background: rgba(255, 255, 255, 0.35);
}

.msg-bubble-reply-author {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--section-color);
    margin-bottom: 2px;
}

.msg-bubble-reply-text {
    display: block;
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-bubble-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.msg-reaction-chip {
    border: 1px solid var(--border-color);
    background: var(--panel-bg);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transform-origin: center bottom;
}

.msg-reaction-chip.is-animating {
    animation: msg-reaction-pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes msg-reaction-pop {
    0% {
        opacity: 0;
        transform: scale(0.35) translateY(6px);
    }
    55% {
        opacity: 1;
        transform: scale(1.14) translateY(-2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.msg-reaction-chip-emoji {
    width: 1.125em;
    height: 1.125em;
    display: block;
    object-fit: contain;
}

.msg-reaction-chip.is-mine {
    border-color: rgba(217, 119, 6, 0.35);
    background: var(--section-soft);
}

.msg-reaction-count {
    margin-left: 4px;
    font-size: 11px;
    color: #64748b;
}

.msg-reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 8px;
    border: 1px solid color-mix(in srgb, var(--section-color) 22%, var(--border-color));
    border-left: 3px solid var(--section-color);
    background: linear-gradient(135deg, var(--section-soft), color-mix(in srgb, var(--panel-bg) 88%, var(--section-soft)));
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

.msg-reply-bar[hidden] {
    display: none !important;
}

.msg-reply-bar-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg-reply-bar-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--section-color);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.msg-reply-bar-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
}

.msg-reply-bar-text {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-reply-bar-close {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.msg-reply-bar-close:hover {
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-edit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 10px 4px 11px;
    margin-bottom: 4px;
    min-height: 0;
    border-left: 2px solid var(--section-color);
    background: color-mix(in srgb, var(--section-soft) 55%, transparent);
    border-radius: 0 6px 6px 0;
}

.msg-edit-bar[hidden] {
    display: none !important;
}

.msg-edit-bar-label {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    letter-spacing: 0;
    line-height: 1.3;
}

.msg-edit-bar-close {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.msg-edit-bar-close:hover {
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-delete-undo-toast {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(420px, calc(100% - 24px));
    padding: 10px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #fff 0%, color-mix(in srgb, var(--section-soft) 55%, #fff) 100%);
    border: 1px solid color-mix(in srgb, var(--section-color) 18%, var(--border-color));
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    animation: msgDeleteUndoIn 0.24s cubic-bezier(0.32, 0.72, 0, 1);
}

.msg-delete-undo-toast[hidden] {
    display: none !important;
}

.msg-panel-compose-inner {
    position: relative;
}

.msg-delete-undo-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.14);
    color: #64748b;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.msg-delete-undo-close:hover {
    background: rgba(148, 163, 184, 0.24);
    color: var(--text-color);
}

.msg-delete-undo-timer {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.msg-delete-undo-timer svg {
    display: block;
    transform: rotate(-90deg);
}

.msg-delete-undo-track {
    stroke: rgba(148, 163, 184, 0.28);
}

.msg-delete-undo-progress {
    stroke: var(--section-color);
    stroke-dasharray: 94.25;
    stroke-dashoffset: 0;
    stroke-linecap: round;
}

.msg-delete-undo-count {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--section-color);
}

.msg-delete-undo-text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
}

.msg-delete-undo-action {
    border: none;
    background: none;
    padding: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--section-color);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.msg-delete-undo-action:hover {
    opacity: 0.75;
}

@keyframes msgDeleteUndoIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes msgDeleteUndoRing {
    from {
        stroke-dashoffset: 0;
    }
    to {
        stroke-dashoffset: -94.25;
    }
}

.msg-reaction-picker {
    position: fixed;
    display: flex;
    gap: 4px;
    padding: 6px;
    border-radius: 999px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    z-index: 3000;
}

.msg-reaction-picker[hidden] {
    display: none !important;
}

.msg-emoji-picker {
    position: fixed;
    display: block;
    width: min(392px, calc(100vw - 24px));
    max-height: min(380px, calc(100vh - 120px));
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px 8px 10px;
    border-radius: 14px;
    background: #f2f2f7;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
    z-index: 3000;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.msg-emoji-picker[hidden] {
    display: none !important;
}

.msg-emoji-group + .msg-emoji-group {
    margin-top: 4px;
}

.msg-emoji-group-title {
    padding: 8px 10px 4px;
    font-size: 12px;
    font-weight: 600;
    color: #8e8e93;
    letter-spacing: 0.02em;
}

.msg-emoji-group-grid {
    display: grid;
    grid-template-columns: repeat(8, 44px);
    justify-content: center;
    gap: 0;
}

.msg-emoji-pick {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.msg-emoji-pick img {
    width: 32px;
    height: 32px;
    display: block;
    pointer-events: none;
}

.msg-emoji-pick:hover,
.msg-emoji-pick:focus-visible {
    background: rgba(0, 0, 0, 0.06);
}

.msg-attach-input {
    display: none;
}

.msg-bubble-attachment {
    display: block;
    margin-bottom: 6px;
    text-decoration: none;
    color: inherit;
}

.msg-bubble-attachment-image {
    border: none;
    padding: 0;
    background: transparent;
    cursor: zoom-in;
    text-align: left;
    max-width: 100%;
    overflow: hidden;
}

.msg-bubble-attachment-image img {
    display: block;
    width: auto;
    height: auto;
    max-width: min(280px, 100%);
    max-height: 220px;
    border-radius: 10px;
    object-fit: contain;
    -webkit-user-drag: none;
    user-select: none;
}

.msg-panel-messages img,
.msg-panel-messages video,
.msg-panel-header img,
.msg-info-sidebar img,
.msg-bubble-avatar,
.msg-bubble-attachment {
    -webkit-user-drag: none;
    user-select: none;
}

.msg-bubble-attachment-file,
.msg-bubble-attachment-kb {
    border: none;
    background: transparent;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.msg-bubble-attachment-kb.msg-bubble-attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid var(--border-color);
}

.msg-bubble-out .msg-bubble-attachment-kb.msg-bubble-attachment-file {
    background: rgba(255, 255, 255, 0.35);
}

.msg-attach-menu {
    position: fixed;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 280px;
    max-width: 320px;
    padding: 8px;
    border-radius: 14px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.16);
    z-index: 3000;
}

.msg-attach-menu[hidden] {
    display: none !important;
}

.msg-attach-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-color);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, transform 0.12s;
}

.msg-attach-menu-item:hover {
    background: var(--section-soft);
}

.msg-attach-menu-item:active {
    transform: scale(0.98);
}

.msg-attach-menu-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 10px;
}

.msg-attach-menu-icon--local {
    background: rgba(217, 119, 6, 0.12);
    color: var(--section-color);
}

.msg-attach-menu-icon--kb {
    background: rgba(19, 154, 140, 0.12);
    color: #139a8c;
}

.msg-attach-menu-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg-attach-menu-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.3;
}

.msg-attach-menu-sub {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.35;
}

.msg-local-picker {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.msg-local-picker[hidden] {
    display: none !important;
}

.msg-local-picker-card {
    width: min(440px, 100%);
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
    overflow: hidden;
}

.msg-local-picker-header,
.msg-kb-picker-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
}

.msg-local-picker-head-main,
.msg-kb-picker-head-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.msg-local-picker-head-icon,
.msg-kb-picker-head-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 11px;
}

.msg-local-picker-head-icon {
    background: rgba(217, 119, 6, 0.12);
    color: var(--section-color);
}

.msg-kb-picker-head-icon {
    background: rgba(19, 154, 140, 0.12);
    color: #139a8c;
}

.msg-local-picker-head-text h3,
.msg-kb-picker-head-text h3 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.msg-local-picker-head-text p,
.msg-kb-picker-head-text p {
    margin-top: 2px;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.35;
}

.msg-local-picker-close,
.msg-kb-picker-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.msg-local-picker-close:hover,
.msg-kb-picker-close:hover {
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-local-picker-body {
    padding: 18px;
}

.msg-local-picker-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 32px 24px;
    border: 2px dashed var(--border-color);
    border-radius: 14px;
    background: var(--bg-color);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.msg-local-picker-drop:hover,
.msg-local-picker-drop.is-drag-over {
    border-color: var(--section-color);
    background: var(--section-soft);
}

.msg-local-picker-drop-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 4px;
    border-radius: 50%;
    background: var(--section-soft);
    color: var(--section-color);
    transition: transform 0.15s;
}

.msg-local-picker-drop.is-drag-over .msg-local-picker-drop-icon {
    transform: scale(1.06);
}

.msg-local-picker-drop-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
}

.msg-local-picker-drop-hint {
    font-size: 13px;
    color: #94a3b8;
}

.msg-local-picker-browse {
    margin-top: 4px;
    padding: 9px 20px;
    border: none;
    border-radius: 999px;
    background: var(--section-color);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.12s;
}

.msg-local-picker-browse:hover {
    opacity: 0.92;
}

.msg-local-picker-browse:active {
    transform: scale(0.97);
}

.msg-local-picker-formats {
    margin-top: 6px;
    font-size: 12px;
    color: #94a3b8;
}

.msg-kb-picker {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.msg-kb-picker[hidden] {
    display: none !important;
}

.msg-kb-picker-card {
    width: min(520px, 100%);
    max-height: min(70vh, 640px);
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
    overflow: hidden;
}

.msg-kb-picker-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.msg-kb-picker-search-wrap {
    position: relative;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.msg-kb-picker-search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    color: #94a3b8;
    pointer-events: none;
}

.msg-kb-picker-search {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.msg-kb-picker-search:focus {
    border-color: var(--section-color);
    box-shadow: 0 0 0 3px var(--section-soft);
}

.msg-kb-picker-list {
    flex: 1;
    min-height: 180px;
    overflow-y: auto;
    padding: 8px;
}

.msg-kb-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.msg-kb-picker-item:hover {
    background: var(--section-soft);
}

.msg-kb-picker-item-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-shrink: 0;
    font-size: 18px;
    overflow: hidden;
    border-radius: 10px;
    background: var(--section-soft);
    border: 1px solid var(--border-color);
}

.msg-kb-picker-item-chevron {
    flex-shrink: 0;
    color: #cbd5e1;
    transition: color 0.15s, transform 0.15s;
}

.msg-kb-picker-item:hover .msg-kb-picker-item-chevron {
    color: var(--section-color);
    transform: translateX(2px);
}

.msg-kb-picker-empty,
.msg-kb-picker-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

.msg-kb-picker-empty-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-kb-picker-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border-color);
    border-top-color: var(--section-color);
    border-radius: 50%;
    animation: msg-kb-spin 0.7s linear infinite;
}

@keyframes msg-kb-spin {
    to { transform: rotate(360deg); }
}

.msg-kb-picker-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.msg-kb-picker-item-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg-kb-picker-item-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-kb-picker-item-meta {
    font-size: 11px;
    color: #94a3b8;
}

.msg-panel-more-menu {
    width: 240px;
}

.msg-compose-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 12px 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--section-soft);
    border: 1px solid var(--border-color);
}

.msg-compose-attachment[hidden] {
    display: none !important;
}

.msg-compose-attachment-preview {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.7);
}

.msg-compose-attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.msg-compose-attachment-file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--section-color);
}

.msg-compose-attachment-meta {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.msg-compose-attachment-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-compose-attachment-remove {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #64748b;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.msg-compose-attachment-remove:hover {
    background: rgba(15, 23, 42, 0.08);
    color: #dc2626;
}

.msg-contact-profile-card {
    max-width: 420px;
}

.msg-contact-profile-body {
    padding: 0 20px 20px;
}

.msg-contact-profile-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 0 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.msg-contact-profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.msg-contact-profile-avatar-text {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--section-soft);
    color: var(--accent-color, #f97316);
    font-size: 24px;
    font-weight: 600;
    flex-shrink: 0;
}

.msg-contact-profile-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.msg-contact-profile-subtitle {
    font-size: 13px;
    color: #64748b;
    margin-top: 2px;
}

.msg-contact-profile-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-contact-profile-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 14px;
}

.msg-contact-profile-label {
    color: #64748b;
    flex-shrink: 0;
}

.msg-contact-profile-value {
    color: var(--text-color);
    text-align: right;
    word-break: break-word;
}

.msg-contact-profile-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 16px;
}

.msg-profile-block-btn {
    background: #dc2626;
}

.msg-profile-block-btn:hover {
    background: #b91c1c;
}

.msg-auto-delete-hint {
    margin: 0;
    font-size: 12px;
    color: #64748b;
    line-height: 1.45;
    text-align: center;
}

.msg-auto-delete-overlay {
    background: rgba(15, 23, 42, 0.38);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.msg-auto-delete-card {
    max-width: 380px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
    animation: msgConfirmSlideIn 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.msg-auto-delete-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 24px 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
    position: relative;
    text-align: center;
}

.msg-auto-delete-header .modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
}

.msg-auto-delete-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--section-soft), color-mix(in srgb, var(--section-color) 12%, #fff));
    color: var(--section-color);
    margin-bottom: 12px;
}

.msg-auto-delete-header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-color);
}

.msg-auto-delete-subtitle {
    margin: 6px 0 0;
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
}

.msg-auto-delete-body {
    padding: 18px 20px 20px;
}

.msg-auto-delete-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.msg-auto-delete-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.msg-auto-delete-option:hover {
    border-color: color-mix(in srgb, var(--section-color) 35%, var(--border-color));
    background: color-mix(in srgb, var(--section-soft) 40%, #fff);
}

.msg-auto-delete-option.is-active {
    border-color: var(--section-color);
    background: var(--section-soft);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--section-color) 14%, transparent);
}

.msg-auto-delete-option-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(148, 163, 184, 0.12);
    color: #64748b;
    transition: background 0.15s ease, color 0.15s ease;
}

.msg-auto-delete-option.is-active .msg-auto-delete-option-icon {
    background: var(--section-color);
    color: #fff;
}

.msg-auto-delete-option-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.msg-auto-delete-option-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.msg-auto-delete-option-desc {
    font-size: 12px;
    color: #64748b;
}

.msg-auto-delete-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
}

.msg-auto-delete-footer .btn-modal-cancel,
.msg-auto-delete-footer .btn-modal-save {
    border-radius: 10px;
    padding: 10px 20px;
}

.msg-auto-delete-select-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.msg-panel-blocked-bar[hidden],
.msg-panel-compose-inner[hidden] {
    display: none !important;
}

.msg-panel-blocked-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0;
}

.msg-panel-blocked-text {
    margin: 0;
    font-size: 14px;
    color: #64748b;
    line-height: 1.4;
}

.msg-panel-unblock-btn {
    flex-shrink: 0;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    background: var(--section-color);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.msg-panel-unblock-btn:hover {
    filter: brightness(0.95);
}

.msg-chat-menu-item.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.msg-bubble-deleted {
    font-size: 13px;
    font-style: italic;
    color: #94a3b8;
    padding: 4px 0;
}

.msg-bubble-context-menu {
    position: fixed;
    z-index: 4000;
    min-width: 248px;
    width: max-content;
    max-width: min(320px, calc(100vw - 16px));
    padding: 6px;
    opacity: 0;
    transform: translateY(4px) scale(0.98);
    transform-origin: top left;
    transition: opacity 0.16s ease, transform 0.16s ease;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.14), 0 0 0 1px rgba(217, 119, 6, 0.06);
}

.msg-bubble-context-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.msg-bubble-context-menu .msg-chat-menu-item svg {
    width: 16px;
    height: 16px;
}

.msg-copy-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(12px);
    z-index: 5000;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.msg-copy-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.msg-forward-card {
    max-width: 420px;
}

.msg-forward-search-wrap {
    padding: 0 16px 12px;
}

.msg-forward-search {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: var(--panel-bg);
    color: var(--text-color);
}

.msg-forward-list {
    max-height: 360px;
    overflow-y: auto;
    padding: 0 8px 12px;
}

.msg-forward-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border: none;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.15s ease;
}

.msg-forward-item:hover {
    background: var(--section-soft);
}

.msg-forward-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.msg-forward-item-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg-forward-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-forward-item-preview {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-forward-empty {
    padding: 24px 16px;
    text-align: center;
    color: #64748b;
    font-size: 14px;
}

.msg-bubble-edited {
    margin-left: 6px;
    font-size: 11px;
    color: #94a3b8;
}

.msg-bubble-row.is-search-hit .msg-bubble {
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.45);
}

.msg-panel-search {
    padding: 0 16px 12px;
    background: var(--panel-bg);
}

.msg-panel-search[hidden] {
    display: none !important;
}

.msg-panel-search-card {
    border: 1px solid color-mix(in srgb, var(--section-color) 18%, var(--border-color));
    border-radius: 14px;
    background: linear-gradient(135deg, #fff, color-mix(in srgb, var(--section-soft) 45%, #fff));
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    animation: msgSearchIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.msg-panel-search-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
}

.msg-panel-search-icon-wrap {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-panel-search-icon {
    flex-shrink: 0;
}

.msg-panel-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    border-radius: 0;
    padding: 8px 4px;
    font-size: 14px;
    background: transparent;
    color: var(--text-color);
    outline: none;
}

.msg-panel-search-input::placeholder {
    color: #94a3b8;
}

.msg-panel-search-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--section-color);
    min-width: 44px;
    text-align: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--section-soft);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.msg-panel-search-count:empty {
    display: none;
}

.msg-panel-search-nav-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.msg-panel-search-nav,
.msg-panel-search-close {
    width: 32px;
    height: 32px;
    border: 1px solid color-mix(in srgb, var(--border-color) 80%, transparent);
    border-radius: 9px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.msg-panel-search-nav:hover,
.msg-panel-search-close:hover {
    background: var(--section-soft);
    color: var(--section-color);
    border-color: color-mix(in srgb, var(--section-color) 25%, var(--border-color));
}

.msg-panel-search-results {
    max-height: 240px;
    overflow: auto;
    border-top: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
    background: rgba(255, 255, 255, 0.72);
}

.msg-panel-search-results[hidden] {
    display: none !important;
}

.msg-panel-search-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 11px 14px;
    border: none;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.msg-panel-search-item:last-child {
    border-bottom: none;
}

.msg-panel-search-item:hover,
.msg-panel-search-item.is-active {
    background: color-mix(in srgb, var(--section-soft) 70%, #fff);
}

.msg-panel-search-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.msg-panel-search-item-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
}

.msg-panel-search-item-time {
    font-size: 11px;
    font-weight: 500;
    color: var(--section-color);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.msg-panel-search-item-snippet {
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.msg-panel-search-empty {
    padding: 20px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

@keyframes msgSearchIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-blocked-list {
    padding: 0 20px 20px;
    max-height: 360px;
    overflow: auto;
}

.msg-blocked-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.msg-blocked-item-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.msg-blocked-item-main span {
    font-size: 12px;
    color: #64748b;
}

.msg-blocked-unblock-btn {
    border: 1px solid var(--border-color);
    background: var(--section-soft);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
}

.msg-blocked-unblock-btn:hover {
    border-color: var(--accent-color, #f97316);
    color: var(--accent-color, #f97316);
}

.msg-blocked-empty {
    padding: 24px 0;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

.msg-kb-viewer-card {
    width: min(960px, calc(100vw - 32px));
    height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
}

/* ── Мессенджер · просмотр файлов ─────────────────────────────── */
.msg-file-viewer-overlay {
    z-index: 320;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(4px);
    padding: 16px;
}

.msg-file-viewer-card {
    width: min(1120px, calc(100vw - 32px));
    height: min(90dvh, 880px);
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border: 1px solid color-mix(in srgb, var(--section-color) 16%, var(--border-color));
    border-radius: 18px;
    overflow: hidden;
    box-shadow:
        0 24px 64px rgba(15, 23, 42, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    animation: msgFileViewerIn 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes msgFileViewerIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg-file-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, var(--panel-bg) 0%, color-mix(in srgb, var(--section-soft) 35%, var(--panel-bg)) 100%);
    flex-shrink: 0;
}

.msg-file-viewer-head-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.msg-file-viewer-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--section-color);
    background: color-mix(in srgb, var(--section-color) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--section-color) 18%, transparent);
}

.msg-file-viewer-head-text {
    min-width: 0;
}

.msg-file-viewer-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(560px, 52vw);
}

.msg-file-viewer-kind {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
}

.msg-file-viewer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.msg-file-viewer-dl {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--section-soft);
    color: var(--section-color);
    border: 1px solid color-mix(in srgb, var(--section-color) 22%, transparent);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.msg-file-viewer-dl:hover {
    background: color-mix(in srgb, var(--section-color) 16%, var(--panel-bg));
    border-color: color-mix(in srgb, var(--section-color) 35%, transparent);
}

.msg-file-viewer-dl:active {
    transform: scale(0.97);
}

.msg-file-viewer-close {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.msg-file-viewer-close:hover {
    background: var(--section-soft);
    color: var(--section-color);
}

.msg-file-viewer-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: color-mix(in srgb, var(--bg-color) 88%, var(--panel-bg));
    padding: 16px;
}

.msg-file-viewer-overlay.is-onlyoffice .msg-file-viewer-body,
.msg-file-viewer-overlay.is-onlyoffice .msg-file-viewer-body.is-oo-active {
    padding: 0;
    overflow: hidden;
    background: #f4f6f8;
}

.msg-file-viewer-loading {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 500;
}

.msg-file-viewer-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--section-color) 18%, transparent);
    border-top-color: var(--section-color);
    animation: msgFileViewerSpin 0.75s linear infinite;
}

@keyframes msgFileViewerSpin {
    to { transform: rotate(360deg); }
}

.msg-file-viewer-overlay.is-image .msg-file-viewer-body {
    justify-content: center;
}

.msg-file-viewer-media {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(920px, 100%);
    margin: auto;
}

.msg-file-viewer-body .kb-viewer-img {
    max-width: 100%;
    max-height: calc(90dvh - 190px);
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
    border: 1px solid var(--border-color);
    background: var(--panel-bg);
}

.msg-file-viewer-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
    margin-top: 18px;
    padding-top: 16px;
    text-align: center;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.msg-file-viewer-meta-kind {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

.msg-file-viewer-meta-datetime {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: #64748b;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}

.msg-file-viewer-body .kb-viewer-iframe {
    width: 100%;
    height: 100%;
    min-height: calc(90dvh - 120px);
    border: none;
    border-radius: 12px;
    background: var(--panel-bg);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
}

.msg-file-viewer-body .kb-viewer-video {
    max-width: 100%;
    max-height: calc(90dvh - 120px);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);
}

.msg-file-viewer-body .kb-viewer-txt {
    width: 100%;
    max-width: 900px;
    margin: 0;
    padding: 16px 18px;
    border-radius: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-color);
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-file-viewer-body .kb-viewer-fallback {
    margin: auto;
    text-align: center;
    padding: 32px 24px;
    border-radius: 14px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.msg-file-viewer-body .kb-vf-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
    margin-top: 8px;
}

.msg-file-viewer-body .kb-vf-hint {
    font-size: 13px;
    color: #94a3b8;
    margin-top: 6px;
}

.msg-file-viewer-body .msg-kb-oo-editor {
    width: 100%;
    height: 100%;
    min-height: calc(90dvh - 72px);
}

body.theme-dark .msg-file-viewer-overlay {
    background: rgba(0, 0, 0, 0.62);
}

body.theme-dark .msg-file-viewer-meta {
    border-top-color: rgba(148, 163, 184, 0.12);
}

body.theme-dark .msg-file-viewer-meta-kind {
    color: #64748b;
}

body.theme-dark .msg-file-viewer-meta-datetime {
    color: #94a3b8;
}

body.theme-dark .msg-file-viewer-overlay.is-onlyoffice .msg-file-viewer-body {
    background: #111827;
}

.msg-kb-viewer-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.msg-kb-viewer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.msg-kb-oo-editor {
    width: 100%;
    height: 100%;
    min-height: 420px;
}

.msg-drop-overlay {
    position: absolute;
    inset: 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--section-color);
    border-radius: 16px;
    background: rgba(217, 119, 6, 0.08);
    pointer-events: none;
}

.msg-drop-overlay[hidden] {
    display: none !important;
}

.msg-drop-overlay-inner {
    padding: 16px 24px;
    border-radius: 999px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 600;
    color: var(--section-color);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

a.msg-bubble-attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid var(--border-color);
    text-decoration: none;
}

.msg-bubble-out a.msg-bubble-attachment-file {
    background: rgba(255, 255, 255, 0.35);
}

.msg-bubble-attachment-name {
    font-size: 13px;
    font-weight: 500;
    word-break: break-word;
}

.msg-panel-compose {
    position: relative;
}

.msg-reaction-pick {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.msg-reaction-pick img {
    width: 28px;
    height: 28px;
    display: block;
    pointer-events: none;
}

.msg-reaction-pick:hover {
    background: var(--section-soft);
}

.msg-bubble-row.is-highlight .msg-bubble {
    animation: msgHighlight 1.2s ease;
}

@keyframes msgHighlight {
    0%, 100% { box-shadow: none; }
    30% { box-shadow: 0 0 0 3px var(--section-soft); }
}

/* ═══════════════════════════════════════════════════════════════════
   МЕССЕНДЖЕР — мобильная адаптация (< 768px)
   ═══════════════════════════════════════════════════════════════════ */

body.section-messenger.msg-chat-open .user-menu-container {
    display: none !important;
}

@media (max-width: 767px) {
    body.section-messenger {
        touch-action: manipulation;
        -webkit-text-size-adjust: 100%;
    }

    body.section-messenger .menu-toggle {
        display: none;
    }

    body.section-messenger .main-content.msg-main {
        display: none;
        padding: 0;
    }

    body.section-messenger:not(.msg-chat-open) .sidebar {
        transform: translateX(0);
        top: var(--header-height);
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
        height: calc(100dvh - var(--header-height));
        box-shadow: none;
        z-index: 5;
    }

    body.section-messenger:not(.msg-chat-open) .sidebar .logo-container {
        display: none;
    }

    body.section-messenger.msg-chat-open .main-content.msg-main {
        display: flex;
        flex-direction: column;
        padding: 0;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    body.section-messenger.msg-chat-open .sidebar {
        display: none;
    }

    body.section-messenger.msg-chat-open .top-navbar,
    body.section-messenger.msg-chat-open .mobile-section-switcher {
        display: none;
    }

    body.section-messenger.msg-chat-open {
        grid-template-rows: 1fr;
        grid-template-areas: "main";
    }

    body.section-messenger .msg-chat-area,
    body.section-messenger .msg-panel-layout,
    body.section-messenger .msg-panel {
        height: 100%;
        min-height: 0;
    }

    body.section-messenger .msg-chat-area {
        border-left: none;
    }

    .msg-panel-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        margin-left: -6px;
        border: none;
        border-radius: 10px;
        background: transparent;
        color: var(--section-color);
        cursor: pointer;
        transition: background 0.15s ease;
    }

    .msg-panel-back-btn:active {
        background: var(--section-soft);
    }

    .msg-panel-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .msg-panel-header-main {
        gap: 8px;
        flex: 1;
    }

    .msg-panel-avatar {
        width: 40px;
        height: 40px;
    }

    .msg-panel-name {
        font-size: 15px;
    }

    .msg-panel-subtitle,
    .msg-panel-status {
        font-size: 12px;
    }

    .msg-panel-header-actions {
        gap: 4px;
    }

    .msg-panel-action-btn[data-action="call"],
    .msg-panel-action-btn[data-action="video"] {
        display: none;
    }

    .msg-panel-action-btn {
        width: 36px;
        height: 36px;
    }

    .msg-panel-body {
        padding: 12px 10px;
    }

    .msg-bubble-row {
        max-width: 88%;
    }

    .msg-bubble-attachment-image {
        max-width: min(260px, 72vw);
    }

    .msg-panel-compose {
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--border-color);
    }

    .msg-panel-form {
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
    }

    .msg-compose-left-tools {
        display: flex;
        align-items: center;
        gap: 0;
        flex-shrink: 0;
    }

    .msg-panel-attach-btn {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        padding: 0;
        border: 1.5px solid #cbd5e1;
        border-radius: 50%;
        background: transparent;
        color: #64748b;
        flex-shrink: 0;
    }

    .msg-panel-attach-btn .msg-compose-attach-icon {
        display: none;
    }

    .msg-panel-attach-btn::before {
        display: block;
        font-size: 20px;
        line-height: 1;
        color: #64748b;
    }

    .msg-panel-emoji-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        border-radius: 50%;
    }

    .msg-panel-autodelete-btn {
        display: none;
    }

    .msg-panel-input-wrap {
        flex: 1 1 0;
        min-width: 0;
    }

    .msg-panel-input-box {
        flex: 1 1 0;
        min-width: 0;
    }

    .msg-panel-input {
        width: 100%;
        min-height: 40px;
        max-height: 120px;
        padding: 10px 16px;
        border: none;
        border-radius: 22px;
        background: #eef1f5;
        font-size: 16px;
        line-height: 1.35;
        box-shadow: none;
    }

    .msg-panel-input:focus {
        box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--section-color) 45%, transparent);
    }

    body.theme-dark .msg-panel-input {
        background: #111827;
    }

    .msg-panel-emoji-infield {
        display: none;
    }

    .msg-panel-voice-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 50%;
        border: none;
        background: var(--section-color);
        color: #fff;
        flex-shrink: 0;
    }

    .msg-panel-voice-btn:hover:not(:disabled) {
        background: #b45309;
        color: #fff;
    }

    .msg-panel-send-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 50%;
        flex-shrink: 0;
        display: none;
    }

    .msg-panel-form.has-compose-text .msg-panel-send-btn,
    .msg-panel-form.has-compose-attachment .msg-panel-send-btn,
    .msg-panel-form.is-edit-mode .msg-panel-send-btn {
        display: flex;
    }

    .msg-panel-form.has-compose-text .msg-panel-voice-btn,
    .msg-panel-form.has-compose-attachment .msg-panel-voice-btn,
    .msg-panel-form.is-edit-mode .msg-panel-voice-btn {
        display: none;
    }

    .msg-panel-compose-btn,
    .msg-panel-voice-btn,
    .msg-panel-send-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .msg-sidebar-tools {
        padding: 10px 12px 8px;
    }

    .msg-filter-tabs {
        padding: 0 12px 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .msg-filter-tabs::-webkit-scrollbar {
        display: none;
    }

    .msg-filter-tab {
        flex: 0 0 auto;
        min-width: max-content;
        padding: 0 14px;
        min-height: 36px;
    }

    .msg-chat-item {
        padding: 12px;
        min-height: 68px;
    }

    .msg-chat-menu-btn {
        width: 40px;
        height: 40px;
        margin: 6px 6px 6px 0;
    }

    body.section-messenger.msg-info-overlay-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 190;
    }

    .msg-panel-layout.is-info-open .msg-info-sidebar {
        position: fixed;
        inset: 0;
        max-width: 100% !important;
        width: 100%;
        z-index: 200;
        border-left: none;
        box-shadow: none;
    }

    .msg-panel-layout.is-info-open .msg-info-sidebar-shell {
        width: 100%;
        min-width: 0;
        animation: none;
    }

    .msg-info-sidebar-header {
        padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
        min-height: 52px;
    }

    .msg-info-sidebar-body {
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .msg-emoji-picker.is-mobile-sheet {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: none !important;
        max-height: min(52dvh, 420px);
        border-radius: 16px 16px 0 0;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .msg-emoji-group-grid {
        grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
        justify-content: stretch;
    }

    .msg-attach-menu.is-mobile-sheet {
        left: 12px !important;
        right: 12px !important;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
        top: auto !important;
        width: auto !important;
        min-width: 0;
        max-width: none;
    }

    .msg-modal-card,
    .msg-forward-card,
    .msg-auto-delete-card,
    .msg-confirm-card {
        max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
    }

    .msg-local-picker,
    .msg-kb-picker {
        padding: 0;
        align-items: flex-end;
    }

    .msg-local-picker-card,
    .msg-kb-picker-card {
        width: 100%;
        max-height: calc(100dvh - env(safe-area-inset-bottom, 0px));
        border-radius: 16px 16px 0 0;
    }

    .msg-lightbox {
        padding: 0;
    }

    .msg-lightbox-stage {
        max-width: 100%;
        max-height: 100dvh;
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .msg-lightbox-close {
        top: calc(12px + env(safe-area-inset-top, 0px));
        right: 12px;
    }

    .msg-lightbox-img {
        max-height: calc(100dvh - 120px);
    }

    .msg-panel-search {
        padding: 8px 10px;
    }

    .msg-panel-search-inner {
        flex-wrap: wrap;
    }

    .msg-panel-search-input {
        flex: 1 1 100%;
        font-size: 16px;
    }

    .msg-delete-undo-toast {
        left: 10px;
        right: 10px;
        max-width: none;
    }

    .msg-file-viewer-overlay {
        padding: 0;
        align-items: stretch;
    }

    .msg-file-viewer-card {
        width: 100%;
        max-height: 100dvh;
        border-radius: 0;
    }

    .msg-file-viewer-header {
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
    }

    .msg-chat-placeholder {
        padding: 24px 16px;
    }

    .msg-contact-list {
        max-height: min(50dvh, 360px);
    }

    .msg-reaction-picker {
        max-width: calc(100vw - 16px);
        flex-wrap: wrap;
        justify-content: center;
    }

    .msg-bubble-context-menu.is-mobile-sheet {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: none;
        border-radius: 16px 16px 0 0;
        padding: 8px 8px calc(12px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.18);
    }

    .msg-bubble-context-menu.is-mobile-sheet .msg-chat-menu-item {
        min-height: 48px;
        font-size: 15px;
        padding: 12px 16px;
    }
}

body.msg-context-menu-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 115;
}

