/* =================================================================
   MOBILE.CSS — Complete mobile interface for TaskBoard
   Single source of truth. Breakpoint: 768px
   ================================================================= */

/* Мобильные элементы скрыты на десктопе */
.mobile-bottom-nav,
.mobile-bottom-bar,
.mobile-app,
.mobile-app-header {
    display: none;
}

/* ================================================================
   LOGIN PAGE
   ================================================================ */

@media (max-width: 768px) {
    .login-container {
        padding: 20px;
        max-width: calc(100% - 40px);
        margin: 20px;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 16px;
        max-width: calc(100% - 20px);
        margin: 10px;
        border-radius: 6px;
    }

    .login-container h2 {
        font-size: 20px;
    }

    .form-group input[type="text"],
    .form-group input[type="password"] {
        padding: 12px;
        font-size: 16px;
    }

    button[type="submit"] {
        padding: 12px 20px;
        font-size: 16px;
    }
}

/* ================================================================
   1. LAYOUT — App wrapper, header, main scroll area, bottom nav
   ================================================================ */

@media (max-width: 768px) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: rgba(30, 41, 59, 0.7);
        --bg-tertiary: rgba(51, 65, 85, 0.5);
        --bg-quaternary: rgba(71, 85, 105, 0.4);
        --accent-primary: #3b82f6;
        --accent-secondary: #14b8a6;
        --accent-border: rgba(255, 255, 255, 0.08);
        --glass-border: rgba(255, 255, 255, 0.1);
        --glass-blur: blur(12px);
        --text-primary: #f8fafc;
        --text-secondary: #e2e8f0;
        --text-muted: #94a3b8;
        --radius-premium: 16px;
        --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    }

    body {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
        background-color: var(--bg-primary) !important;
        color: var(--text-primary) !important;
        box-sizing: border-box;
    }

    *,
    *::before,
    *::after {
        box-sizing: inherit;
    }

    /* Hide ALL desktop elements */
    .app-header,
    .mobile-board-bar,
    .filters-bar,
    .board-container,
    .kanban-board,
    #kanbanBoard,
    .column-dots,
    .chat-sidebar,
    #chatSidebar,
    .open-chat-btn,
    #openChatBtn,
    #mobileSidebar,
    #sidebarOverlay,
    .sidebar-overlay,
    .desktop-board,
    .board-columns-container,
    .mobile-hidden {
        display: none !important;
    }

    /* Prevent body scroll — mobile shell takes over */
    body {
        overflow: hidden;
    }

    /* Full-screen app shell */
    .mobile-app {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 0;
        overflow: hidden;
        background: var(--bg-primary, #1a1a2e);
    }

    /* Main scrollable area — between header and nav */
    .mobile-main-content {
        flex: 1;
        overflow: hidden;
        padding-top: calc(64px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        z-index: 5;
    }

    /* Accordion wrapper — injected directly into body by taskboard.ts */
    #mobileAccordionWrapper,
    .mobile-accordion-wrapper {
        position: fixed;
        top: calc(64px + env(safe-area-inset-top, 0px));
        left: 0;
        right: 0;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        overflow: hidden;
        background: var(--bg-primary);
        z-index: 10;
    }
    /* ================================================================
       2. HEADER COMPONENT
       ================================================================ */
    .mobile-app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 400;
        height: calc(64px + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding-left: 16px;
        padding-right: 16px;
        background: var(--bg-secondary);
        backdrop-filter: var(--glass-blur);
        border-bottom: 1px solid var(--accent-border);
        -webkit-backdrop-filter: var(--glass-blur);
        border-bottom: 1px solid var(--glass-border);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .header-left {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0;
        flex: 1;
    }

    .app-logo-mini {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    .board-name-btn {
        display: flex;
        align-items: center;
        gap: 6px;
        background: none;
        border: none;
        color: var(--text-primary);
        padding: 4px 0;
        min-width: 0;
        cursor: pointer;
    }

    .board-name {
        font-size: 18px;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: -0.02em;
    }

    .board-name-btn .chevron {
        color: var(--text-muted);
        opacity: 0.7;
    }

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

    .notification-btn {
        position: relative;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-tertiary);
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        color: var(--text-primary);
        cursor: pointer;
        transition: transform 0.2s;
    }

    .notification-btn:active {
        transform: scale(0.95);
        background: var(--bg-quaternary);
    }

    .notification-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 18px;
        height: 18px;
        background: #ef4444;
        color: white;
        font-size: 10px;
        font-weight: 700;
        border-radius: 50%;
        border: 2px solid var(--bg-primary);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .premium-avatar-btn {
        background: none;
        border: none;
        padding: 0;
        cursor: pointer;
        transition: transform 0.2s;
    }

    .premium-avatar-btn:active {
        transform: scale(0.95);
    }

    .user-avatar-circle {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--accent-primary) 0%, #60a5fa 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-weight: 600;
        font-size: 14px;
        border: 2px solid var(--glass-border);
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    }

    /* ================================================================
       3. BOTTOM NAV COMPONENT
       ================================================================ */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 400;
        height: calc(72px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        display: flex;
        align-items: center;
        justify-content: space-around;
        background: var(--bg-secondary);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        border-top: 1px solid var(--glass-border);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    }

    .nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        position: relative;
        transition: all 0.2s;
        padding: 4px;
        -webkit-tap-highlight-color: transparent;
    }

    .nav-icon-container {
        position: relative;
        width: 48px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 16px;
        transition: all 0.2s;
    }

    .nav-item.active {
        color: var(--accent-primary);
    }

    .nav-item.active .nav-icon-container {
        background: rgba(59, 130, 246, 0.15);
        color: var(--accent-primary);
    }

    .nav-item span {
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.02em;
    }

    .chat-badge {
        position: absolute;
        top: -4px;
        right: 4px;
        min-width: 18px;
        height: 18px;
        background: #ef4444;
        color: white;
        font-size: 10px;
        font-weight: 700;
        border-radius: 50%;
        border: 2px solid var(--bg-secondary);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ================================================================
       4. BOARD VIEW — Tabs & Viewport
       ================================================================ */
    .mobile-board-view {
        display: flex;
        flex-direction: column;
        height: 100%;
        background: var(--bg-primary);
        position: relative;
    }

    .mobile-tabs-container {
        padding-top: 12px;
        background: var(--bg-primary);
        flex-shrink: 0;
    }

    .mobile-tabs-list {
        display: flex;
        overflow-x: auto;
        padding: 0 16px 12px;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .mobile-tabs-list::-webkit-scrollbar { display: none; }

    .mobile-tab {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 16px;
        background: var(--bg-secondary);
        border: 1px solid var(--accent-border);
        border-radius: 100px;
        color: var(--text-secondary);
        white-space: nowrap;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-tab.active {
        background: var(--accent-primary);
        color: white;
        border-color: transparent;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
        transform: translateY(-1px);
    }

    .tab-color {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .tab-count {
        background: rgba(255, 255, 255, 0.15);
        padding: 2px 6px;
        border-radius: 10px;
        font-size: 11px;
        min-width: 18px;
        text-align: center;
    }

    .mobile-tab-add {
        width: 36px;
        height: 36px;
        border-radius: 18px;
        background: var(--bg-tertiary);
        border: 1px dashed var(--accent-border);
        color: var(--text-muted);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-cards-viewport {
        flex: 1;
        overflow-y: auto;
        padding-bottom: 100px;
    }

    .empty-column-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 60px 24px;
        text-align: center;
        color: var(--text-muted);
    }

    .empty-icon {
        font-size: 48px;
        margin-bottom: 16px;
    }

    .mobile-fab {
        position: fixed;
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
        right: 20px;
        width: 60px;
        height: 60px;
        border-radius: 30px;
        background: var(--accent-primary);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
        border: 2px solid rgba(255, 255, 255, 0.1);
        z-index: 300;
        cursor: pointer;
        transition: transform 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-fab:active {
        transform: scale(0.9);
    }
i    /* ================================================================
       5. MOBILE CARDS
       ================================================================ */
    .cards-list {
        padding: 4px 16px;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .premium-card {
        background: var(--bg-secondary);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        border: 1px solid var(--accent-border);
        border-radius: var(--radius-premium);
        position: relative;
        overflow: hidden;
        box-shadow: var(--shadow-premium);
        transition: transform 0.2s, background 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .premium-card:active {
        transform: scale(0.98);
        background: var(--bg-tertiary);
    }

    .card-glass-glow {
        position: absolute;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        background: radial-gradient(circle at center, rgba(255,255,255,0.03) 0%, transparent 70%);
        pointer-events: none;
    }

    .card-content {
        padding: 16px;
        display: flex;
        flex-direction: column;
    }

    .card-badges {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 10px;
    }

    .card-pill {
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        padding: 2px 10px;
        border-radius: 100px;
        letter-spacing: 0.05em;
    }

    .card-id-pill {
        font-size: 10px;
        font-weight: 600;
        color: var(--text-muted);
        background: var(--bg-tertiary);
        padding: 2px 8px;
        border-radius: 100px;
    }

    .card-title {
        font-size: 16px;
        font-weight: 600;
        color: var(--text-primary);
        margin: 0 0 6px 0;
        line-height: 1.4;
    }

    .card-desc {
        font-size: 13px;
        color: var(--text-secondary);
        margin: 0 0 16px 0;
        opacity: 0.8;
        line-height: 1.5;
    }

    .card-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-top: 1px solid var(--accent-border);
        padding-top: 12px;
        margin-top: 4px;
    }

    .card-meta {
        display: flex;
        gap: 12px;
    }

    .meta-badge {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 11px;
        color: var(--text-muted);
        font-weight: 500;
    }

    .meta-badge.overdue {
        color: #ef4444;
    }

    .mini-avatar {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--accent-primary) 0%, #60a5fa 100%);
        color: white;
        font-size: 10px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 2px solid var(--bg-secondary);
        box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    }

    .card-desc {
        color: var(--text-muted, #888);
        font-size: 13px;
    }

    .add-card-btn-full {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: calc(100% - 24px);
        margin: 8px 12px 12px;
        padding: 10px;
        background: none;
        border: 1px dashed var(--accent-border, rgba(122, 158, 245, 0.2));
        border-radius: var(--radius-md, 8px);
        color: var(--text-muted, #888);
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        min-height: 44px;
        transition: border-color 0.2s, color 0.2s;
    }

    .add-card-btn-full:active {
        border-color: var(--accent-primary, #007bff);
        color: var(--accent-primary, #007bff);
    }

    .empty-accordion {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 60px 24px;
        color: var(--text-muted, #888);
        text-align: center;
    }

    .empty-accordion p {
        font-size: 15px;
        font-weight: 500;
    }

    .accordion-add-column-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: calc(100% - 32px);
        margin: 8px 16px 16px;
        padding: 13px 16px;
        background: none;
        border: 1.5px dashed var(--accent-border, rgba(122, 158, 245, 0.3));
        border-radius: var(--radius-md, 8px);
        color: var(--text-muted, #888);
        font-size: 14px;
        font-family: inherit;
        cursor: pointer;
        transition: border-color 0.15s, color 0.15s;
    }

    .accordion-add-column-btn:active {
        border-color: var(--accent-primary, #7a9ef5);
        color: var(--accent-primary, #7a9ef5);
    }

    /* ================================================================
       6. BOTTOM SHEETS — Common modal pattern
       ================================================================ */

    .mobile-modal-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 650;
        display: flex;
        align-items: flex-end;
        animation: fadeIn 0.2s ease;
    }

    .mobile-bottom-sheet {
        width: 100%;
        background: var(--bg-secondary, #2a2a4a);
        border-radius: 16px 16px 0 0;
        max-height: 90vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .modal-drag-handle {
        width: 36px;
        height: 4px;
        background: var(--bg-quaternary, #4a4a6e);
        border-radius: 2px;
        margin: 12px auto 4px;
        flex-shrink: 0;
        cursor: pointer;
    }

    .modal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 4px 16px 12px;
        flex-shrink: 0;
    }

    .modal-header h2 {
        font-size: 17px;
        font-weight: 600;
        color: var(--text-primary, #e0e0e0);
        margin: 0;
    }

    .mobile-bottom-sheet .modal-close-btn {
        display: none;
    }

    .modal-close-btn {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-radius: var(--radius-md, 8px);
        color: var(--text-muted, #888);
        cursor: pointer;
        flex-shrink: 0;
    }

    .modal-close-btn:active {
        background: var(--bg-tertiary, #3a3a5e);
    }

    .modal-content-scrollable {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
        flex: 1;
    }

    /* ================================================================
       Menu items inside bottom sheets
       ================================================================ */

    .menu-section {
        display: flex;
        flex-direction: column;
        gap: 2px;
        margin-bottom: 8px;
    }

    .menu-section-label {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-muted, #888);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        padding: 8px 4px 4px;
    }

    .menu-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 12px;
        border-radius: var(--radius-md, 8px);
        min-height: 52px;
        background: none;
        border: none;
        color: var(--text-primary, #e0e0e0);
        font-size: 15px;
        font-weight: 500;
        cursor: pointer;
        width: 100%;
        text-align: left;
        transition: background 0.15s ease;
    }

    .menu-item:active {
        background: var(--bg-tertiary, #3a3a5e);
    }

    .menu-item.active-board {
        color: var(--accent-primary, #007bff);
    }

    .menu-item-danger {
        color: var(--color-danger, #ff4136);
    }

    .menu-chevron {
        margin-left: auto;
        color: var(--text-muted, #888);
        flex-shrink: 0;
    }

    .menu-empty-hint {
        padding: 16px 12px;
        color: var(--text-muted, #888);
        font-size: 14px;
    }

    /* ================================================================
       7. FORMS — Mobile input styles
       ================================================================ */

    .mobile-form {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .mobile-form-label {
        font-size: 13px;
        font-weight: 500;
        color: var(--text-muted, #888);
        display: block;
        margin-bottom: -4px;
    }

    .mobile-form-input,
    .mobile-form-textarea {
        width: 100%;
        background: var(--bg-tertiary, #3a3a5e);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        border-radius: var(--radius-md, 8px);
        color: var(--text-primary, #e0e0e0);
        padding: 12px;
        font-size: 16px; /* prevents iOS zoom */
        font-family: inherit;
        box-sizing: border-box;
        outline: none;
        transition: border-color 0.2s ease;
        -webkit-appearance: none;
        appearance: none;
    }

    .mobile-form-input:focus,
    .mobile-form-textarea:focus {
        border-color: var(--accent-primary, #007bff);
    }

    .mobile-form-input.error,
    .mobile-form-textarea.error {
        border-color: var(--color-danger, #ff4136);
    }

    .mobile-form-textarea {
        resize: none;
        min-height: 80px;
        line-height: 1.5;
    }

    .mobile-form-submit {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        height: 48px;
        background: var(--gradient-button, linear-gradient(135deg, #4a4a6e 0%, #3a3a5e 100%));
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        border-radius: var(--radius-md, 8px);
        color: var(--text-primary, #e0e0e0);
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
        transition: opacity 0.2s;
        font-family: inherit;
    }

    .mobile-form-submit:active {
        opacity: 0.8;
    }

    .mobile-form-submit:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    /* Custom picker button (replaces native select) */
    .mobile-form-picker {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 10px;
        background: var(--bg-tertiary, #3a3a5e);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        border-radius: var(--radius-md, 8px);
        color: var(--text-primary, #e0e0e0);
        padding: 12px;
        font-size: 15px;
        font-family: inherit;
        text-align: left;
        cursor: pointer;
        min-height: 48px;
        transition: border-color 0.2s;
    }

    .mobile-form-picker:active {
        border-color: var(--accent-primary, #007bff);
    }

    .mobile-form-picker span {
        flex: 1;
    }

    .mobile-form-picker svg:first-child {
        color: var(--text-muted, #888);
        flex-shrink: 0;
    }

    .picker-chevron {
        color: var(--text-muted, #888);
        flex-shrink: 0;
    }

    .menu-item-avatar {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: var(--accent-primary, #007bff);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        font-weight: 700;
        flex-shrink: 0;
    }

    .check-icon {
        margin-left: auto;
        color: var(--accent-primary, #007bff);
        flex-shrink: 0;
    }

    /* Priority selector */
    .priority-select-group {
        display: flex;
        gap: 8px;
    }

    .priority-btn {
        flex: 1;
        padding: 10px 6px;
        border-radius: var(--radius-md, 8px);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        background: none;
        color: var(--text-muted, #888);
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        transition: border-color 0.2s, color 0.2s;
        font-family: inherit;
        min-height: 44px;
    }

    .priority-btn.active[data-priority="low"] {
        border-color: var(--priority-low, #3d9970);
        color: var(--priority-low, #3d9970);
        background: rgba(61, 153, 112, 0.1);
    }

    .priority-btn.active[data-priority="medium"] {
        border-color: var(--priority-medium, #ff851b);
        color: var(--priority-medium, #ff851b);
        background: rgba(255, 133, 27, 0.1);
    }

    .priority-btn.active[data-priority="high"] {
        border-color: var(--priority-high, #ff4136);
        color: var(--priority-high, #ff4136);
        background: rgba(255, 65, 54, 0.1);
    }

    .priority-btn.active[data-priority="urgent"] {
        border-color: #c44dff;
        color: #c44dff;
        background: rgba(180, 0, 255, 0.1);
    }

    .mobile-form-select {
        width: 100%;
        background: var(--bg-tertiary, #3a3a5e);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        border-radius: var(--radius-md, 8px);
        color: var(--text-primary, #e0e0e0);
        padding: 12px;
        font-size: 16px;
        font-family: inherit;
        box-sizing: border-box;
        outline: none;
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 36px;
        cursor: pointer;
        transition: border-color 0.2s ease;
    }

    .mobile-form-select:focus {
        border-color: var(--accent-primary, #007bff);
    }

    .mobile-form-select option {
        background: var(--bg-secondary, #2a2a4a);
        color: var(--text-primary, #e0e0e0);
    }

    /* Generic button styles */
    .btn-primary {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 10px 20px;
        min-height: 44px;
        background: var(--accent-primary, #007bff);
        color: #fff;
        border: none;
        border-radius: var(--radius-md, 8px);
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        font-family: inherit;
    }

    /* ================================================================
       8. FULL-SCREEN CARD MODAL
       ================================================================ */

    .mobile-card-fullscreen {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100dvh; /* shrinks when iOS keyboard appears */
        z-index: 600;
        background: var(--bg-primary, #1a1a2e);
        display: flex;
        flex-direction: column;
        animation: fadeIn 0.2s ease;
        overflow: hidden;
    }

    .card-fs-header {
        display: flex;
        align-items: center;
        gap: 8px;
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: 8px;
        padding-right: 8px;
        padding-bottom: 0;
        min-height: calc(56px + env(safe-area-inset-top, 0px));
        background: var(--bg-secondary, #2a2a4a);
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        flex-shrink: 0;
    }

    .card-fs-back {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-radius: var(--radius-md, 8px);
        color: var(--text-primary, #e0e0e0);
        cursor: pointer;
        flex-shrink: 0;
    }

    .card-fs-back:active {
        background: var(--bg-tertiary, #3a3a5e);
    }

    .card-fs-id {
        font-size: 13px;
        color: var(--text-muted, #888);
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .card-fs-delete {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-radius: var(--radius-md, 8px);
        color: var(--color-danger, #ff4136);
        cursor: pointer;
        flex-shrink: 0;
        opacity: 0.8;
    }

    .card-fs-delete:active {
        background: rgba(255, 65, 54, 0.12);
        opacity: 1;
    }


    .card-fs-tabs {
        display: flex;
        background: var(--bg-secondary, #2a2a4a);
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        flex-shrink: 0;
    }

    .card-fs-tab {
        flex: 1;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-size: 13px;
        font-weight: 500;
        color: var(--text-muted, #888);
        background: none;
        border: none;
        border-bottom: 2px solid transparent;
        cursor: pointer;
        transition: color 0.2s, border-color 0.2s;
        font-family: inherit;
    }

    .card-fs-tab.active {
        color: var(--accent-primary, #007bff);
        border-bottom-color: var(--accent-primary, #007bff);
    }

    .card-fs-tab-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        background: var(--bg-tertiary, #3a3a5e);
        color: var(--text-secondary, #cccccc);
        font-size: 11px;
        font-weight: 600;
        border-radius: 9px;
    }

    .card-fs-body {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .card-fs-task-wrapper {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
    }

    .card-fs-task {
        flex: 1;
        padding: 20px 16px 8px;
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    /* Hero: title + priority/tags row */
    .card-fs-hero {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .card-fs-title {
        font-size: 20px;
        font-weight: 700;
        color: var(--text-primary, #e0e0e0);
        line-height: 1.35;
        margin: 0;
        word-break: break-word;
    }

    .card-fs-hero-meta {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
    }

    .priority-pill {
        display: inline-flex;
        align-items: center;
        padding: 3px 10px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 600;
        flex-shrink: 0;
    }

    .priority-pill-low {
        background: rgba(61, 153, 112, 0.15);
        color: var(--priority-low, #3d9970);
        border: 1px solid rgba(61, 153, 112, 0.25);
    }

    .priority-pill-medium {
        background: rgba(255, 133, 27, 0.15);
        color: var(--priority-medium, #ff851b);
        border: 1px solid rgba(255, 133, 27, 0.25);
    }

    .priority-pill-high {
        background: rgba(255, 65, 54, 0.15);
        color: var(--priority-high, #ff4136);
        border: 1px solid rgba(255, 65, 54, 0.25);
    }

    .priority-pill-urgent {
        background: rgba(180, 0, 255, 0.15);
        color: #c44dff;
        border: 1px solid rgba(180, 0, 255, 0.25);
    }

    .card-fs-tag {
        display: inline-flex;
        align-items: center;
        font-size: 12px;
        padding: 3px 9px;
        border-radius: 20px;
        background: color-mix(in srgb, var(--tag-color, #888) 18%, transparent);
        color: var(--tag-color, #aaa);
        border: 1px solid color-mix(in srgb, var(--tag-color, #888) 35%, transparent);
    }

    /* Meta list */
    .card-fs-meta-list {
        display: flex;
        flex-direction: column;
        background: var(--bg-secondary, #2a2a4a);
        border-radius: var(--radius-md, 8px);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.15));
        overflow: hidden;
    }

    .card-fs-meta-row {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 11px 14px;
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.1));
        width: 100%;
        box-sizing: border-box;
        min-width: 0;
        overflow: hidden;
        background: none;
        border-left: none;
        border-right: none;
        border-top: none;
        text-align: left;
        font-family: inherit;
        color: inherit;
        cursor: default;
    }

    .card-fs-meta-row:last-child {
        border-bottom: none;
    }

    .card-fs-meta-row-btn {
        cursor: pointer;
    }

    .card-fs-meta-row-btn:active {
        background: var(--bg-tertiary, #3a3a5e);
    }

    .card-fs-meta-chevron {
        color: var(--text-muted, #888);
        flex-shrink: 0;
    }

    .card-fs-meta-icon {
        color: var(--text-muted, #888);
        display: flex;
        align-items: center;
        flex-shrink: 0;
        width: 18px;
    }

    .card-fs-meta-icon.icon-danger {
        color: var(--color-danger, #ff4136);
    }

    .card-fs-meta-label {
        font-size: 13px;
        color: var(--text-muted, #888);
        flex-shrink: 0;
    }

    .card-fs-meta-val {
        font-size: 13px;
        font-weight: 500;
        color: var(--text-primary, #e0e0e0);
        text-align: right;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
        flex: 1;
    }

    .card-fs-meta-val.overdue {
        color: var(--color-danger, #ff4136);
    }

    /* Description section */
    .card-fs-section {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .card-fs-section-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .card-fs-section-title {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-muted, #888);
        text-transform: uppercase;
        letter-spacing: 0.07em;
    }

    .card-fs-section-btn {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        padding: 5px 10px;
        background: var(--bg-secondary, #2a2a4a);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        border-radius: var(--radius-sm, 4px);
        color: var(--text-secondary, #cccccc);
        font-size: 12px;
        font-weight: 500;
        cursor: pointer;
        font-family: inherit;
        min-height: 30px;
        transition: background 0.15s;
    }

    .card-fs-section-btn:active {
        background: var(--bg-tertiary, #3a3a5e);
    }

    .card-fs-description {
        font-size: 14px;
        line-height: 1.65;
        color: var(--text-primary, #e0e0e0);
        background: var(--bg-secondary, #2a2a4a);
        border-radius: var(--radius-md, 8px);
        padding: 12px 14px;
        min-height: 56px;
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.15));
        word-break: break-word;
    }

    .card-fs-empty-desc {
        font-style: italic;
        color: var(--text-muted, #888);
        font-size: 13px;
    }

    .card-fs-section-badge {
        font-size: 11px;
        font-weight: 600;
        color: var(--accent-primary, #7a9ef5);
        background: rgba(122, 158, 245, 0.12);
        border-radius: 10px;
        padding: 2px 8px;
    }

    .card-fs-subtasks {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .card-fs-subtask {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
        color: var(--text-primary, #e0e0e0);
        background: var(--bg-secondary, #2a2a4a);
        border-radius: var(--radius-sm, 4px);
        padding: 8px 10px;
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.15));
    }

    .card-fs-subtask.completed {
        color: var(--text-muted, #888);
        text-decoration: line-through;
    }

    .card-fs-subtask.completed svg {
        color: var(--success, #4caf50);
        stroke: var(--success, #4caf50);
    }

    .card-fs-subtask svg {
        flex-shrink: 0;
        color: var(--text-muted, #888);
    }


    /* Comments tab */
    .card-fs-comments {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .comments-list {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    /* Comment item: avatar + content in a row */
    .comment-item {
        display: flex;
        gap: 10px;
        align-items: flex-start;
    }

    .comment-item.reply {
        margin-left: 28px;
        padding-left: 12px;
        border-left: 2px solid var(--accent-border, rgba(122, 158, 245, 0.25));
    }

    .comment-avatar {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        background: var(--accent-primary, #007bff);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        font-weight: 700;
        flex-shrink: 0;
        margin-top: 2px;
    }

    .comment-item.reply .comment-avatar {
        width: 24px;
        height: 24px;
        font-size: 10px;
        background: var(--bg-tertiary, #3a3a5e);
    }

    .comment-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 0;
    }

    .comment-header {
        display: flex;
        align-items: baseline;
        gap: 6px;
    }

    .comment-author {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-primary, #e0e0e0);
    }

    .comment-time {
        font-size: 11px;
        color: var(--text-muted, #888);
    }

    .comment-bubble {
        background: var(--bg-secondary, #2a2a4a);
        border-radius: 4px 12px 12px 12px;
        padding: 8px 12px;
        font-size: 14px;
        line-height: 1.55;
        color: var(--text-primary, #e0e0e0);
        word-break: break-word;
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.12));
    }

    .comment-item.reply .comment-bubble {
        background: var(--bg-tertiary, #3a3a5e);
    }

    .comment-footer {
        display: flex;
        gap: 4px;
        align-items: center;
        margin-top: 1px;
    }

    .comment-reply-btn,
    .comment-delete-btn {
        display: inline-flex;
        align-items: center;
        padding: 3px 8px;
        background: none;
        border: none;
        font-size: 12px;
        cursor: pointer;
        font-family: inherit;
        min-height: 28px;
        border-radius: 4px;
        transition: background 0.15s;
    }

    .comment-reply-btn { color: var(--text-muted, #888); }
    .comment-reply-btn:active { color: var(--accent-primary, #007bff); background: rgba(0, 123, 255, 0.08); }

    .comment-delete-btn { color: var(--color-danger, #ff4136); }
    .comment-delete-btn:active { background: rgba(255, 65, 54, 0.08); }

    .comment-attachments {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 4px;
    }

    .comment-attach-link {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 12px;
        color: var(--accent-primary, #007bff);
        text-decoration: none;
        padding: 3px 8px;
        background: rgba(0, 123, 255, 0.08);
        border-radius: 4px;
    }

    /* Reply hint bar */
    .comment-reply-hint {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 6px 12px;
        background: var(--bg-tertiary, #3a3a5e);
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.15));
        font-size: 12px;
        color: var(--text-muted, #888);
        flex-shrink: 0;
    }

    .comment-reply-hint span { flex: 1; }

    .reply-cancel-btn {
        background: none;
        border: none;
        color: var(--text-muted, #888);
        cursor: pointer;
        padding: 4px;
        display: flex;
        align-items: center;
        min-height: 28px;
        min-width: 28px;
    }

    /* Input area */
    .comment-input-area {
        border-top: 1px solid var(--accent-border, rgba(122, 158, 245, 0.15));
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        background: var(--bg-secondary, #2a2a4a);
        flex-shrink: 0;
    }

    .comment-input-row {
        display: flex;
        gap: 8px;
        align-items: flex-end;
    }

    .comment-textarea {
        flex: 1;
        background: var(--bg-primary, #1a1a2e);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        border-radius: var(--radius-md, 8px);
        color: var(--text-primary, #e0e0e0);
        font-size: 16px;
        font-family: inherit;
        padding: 10px 12px;
        resize: none;
        min-height: 42px;
        max-height: 120px;
        outline: none;
        line-height: 1.4;
        transition: border-color 0.2s;
        -webkit-appearance: none;
        appearance: none;
    }

    .comment-textarea:focus {
        border-color: var(--accent-primary, #007bff);
    }

    .comment-send-btn {
        width: 42px;
        height: 42px;
        background: var(--accent-primary, #007bff);
        border: none;
        border-radius: var(--radius-md, 8px);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        transition: opacity 0.15s;
    }

    .comment-send-btn:active { opacity: 0.75; }

    .comments-empty,
    .comments-loading {
        text-align: center;
        padding: 40px 20px;
        color: var(--text-muted, #888);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        font-size: 14px;
    }

    /* ================================================================
       9. FULL-SCREEN CHAT
       ================================================================ */

    .mobile-chat-overlay {
        position: fixed;
        inset: 0;
        /* Фон закрывает доску в зазоре под клавиатурой.
           Высота overlay всегда = весь экран; только внутренний
           .mobile-chat-fullscreen сжимается под visualViewport. */
        background: var(--bg-primary, #1a1a2e);
        z-index: 600;
        overflow: hidden;
    }

    .mobile-chat-fullscreen {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        background: var(--bg-primary, #1a1a2e);
        animation: fadeIn 0.2s ease;
        overflow: hidden;
    }

    .chat-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: 8px;
        padding-right: 8px;
        min-height: calc(56px + env(safe-area-inset-top, 0px));
        background: var(--bg-secondary, #2a2a4a);
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        flex-shrink: 0;
    }

    .chat-fs-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: 8px;
        padding-right: 8px;
        min-height: calc(56px + env(safe-area-inset-top, 0px));
        background: var(--bg-secondary, #2a2a4a);
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        flex-shrink: 0;
    }

    .back-btn,
    .chat-fs-back {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-radius: var(--radius-md, 8px);
        color: var(--text-primary, #e0e0e0);
        cursor: pointer;
        flex-shrink: 0;
    }

    .back-btn:active,
    .chat-fs-back:active {
        background: var(--bg-tertiary, #3a3a5e);
    }

    #mobileChatTitle,
    .chat-fs-title {
        flex: 1;
        font-size: 16px;
        font-weight: 600;
        color: var(--text-primary, #e0e0e0);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-chat-tabs {
        background: var(--bg-secondary, #2a2a4a);
        padding: 8px 16px;
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        flex-shrink: 0;
    }

    .chat-fs-tabs {
        background: var(--bg-secondary, #2a2a4a);
        padding: 8px 16px 0;
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        flex-shrink: 0;
    }

    .mobile-chat-tabs-inner,
    .chat-tab-group {
        display: flex;
        background: var(--bg-tertiary, #3a3a5e);
        border-radius: 20px;
        padding: 3px;
        gap: 2px;
    }

    .chat-tab {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px 16px;
        border-radius: 16px;
        font-size: 14px;
        font-weight: 500;
        color: var(--text-muted, #888);
        background: none;
        border: none;
        cursor: pointer;
        transition: background 0.2s, color 0.2s;
        font-family: inherit;
        min-height: 36px;
    }

    .chat-tab.active {
        background: var(--accent-primary, #007bff);
        color: #fff;
    }

    .chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 16px;
        display: flex;
        flex-direction: column;
        gap: 4px;
        overscroll-behavior: contain;
    }

    .chat-fs-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 16px;
        display: flex;
        flex-direction: column;
        gap: 4px;
        overscroll-behavior: contain;
    }

    /* Chat messages */
    .chat-message {
        display: flex;
        align-items: flex-start;
        gap: 8px;
    }

    .chat-message.own {
        flex-direction: row-reverse;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: var(--bg-tertiary, #3a3a5e);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 13px;
        font-weight: 600;
        color: var(--text-secondary, #cccccc);
        flex-shrink: 0;
    }

    .message-avatar-placeholder {
        width: 32px;
        flex-shrink: 0;
    }

    .message-content {
        display: flex;
        flex-direction: column;
        gap: 2px;
        max-width: 80vw;
    }

    .chat-message.own .message-content {
        align-items: flex-end;
    }

    .message-header {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .message-username {
        font-size: 12px;
        font-weight: 600;
        color: var(--text-muted, #888);
    }

    .message-time {
        font-size: 11px;
        color: var(--text-muted, #888);
    }

    .message-text,
    .msg-bubble {
        background: var(--bg-secondary, #2a2a4a);
        border-radius: 12px;
        padding: 8px 12px;
        font-size: 14px;
        color: var(--text-primary, #e0e0e0);
        word-break: break-word;
        line-height: 1.5;
    }

    .chat-message.own .message-text,
    .chat-message.own .msg-bubble {
        background: var(--accent-primary, #007bff);
        color: #fff;
    }

    /* Msg avatar for new style */
    .msg-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: var(--bg-tertiary, #3a3a5e);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 13px;
        font-weight: 600;
        color: var(--text-secondary, #cccccc);
        flex-shrink: 0;
    }

    .msg-content {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .msg-username {
        font-size: 12px;
        color: var(--text-muted, #888);
    }

    /* Chat input area */
    .chat-input-area {
        border-top: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        background: var(--bg-secondary, #2a2a4a);
        display: flex;
        gap: 8px;
        align-items: flex-end;
        flex-shrink: 0;
    }

    .chat-fs-input-area {
        border-top: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        background: var(--bg-secondary, #2a2a4a);
        display: flex;
        gap: 8px;
        align-items: flex-end;
        flex-shrink: 0;
    }

    #mobileChatInput,
    .chat-input {
        flex: 1;
        background: var(--bg-primary, #1a1a2e);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        border-radius: 20px;
        padding: 10px 16px;
        font-size: 16px; /* prevents iOS zoom */
        font-family: inherit;
        color: var(--text-primary, #e0e0e0);
        resize: none;
        outline: none;
        line-height: 1.4;
        -webkit-appearance: none;
        appearance: none;
    }

    .send-btn,
    .chat-send-btn {
        width: 40px;
        height: 40px;
        background: var(--accent-primary, #007bff);
        border: none;
        border-radius: 50%;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
    }

    .send-btn:active,
    .chat-send-btn:active {
        opacity: 0.8;
    }

    /* DM list */
    .dm-user-list {
        display: flex;
        flex-direction: column;
    }

    .dm-user-item,
    .dm-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .dm-user-item:active,
    .dm-item:active {
        background: var(--bg-secondary, #2a2a4a);
    }

    .dm-avatar {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--bg-tertiary, #3a3a5e);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        font-weight: 600;
        color: var(--text-secondary, #cccccc);
        flex-shrink: 0;
    }

    .dm-user-info,
    .dm-info {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
        overflow: hidden;
    }

    .dm-username,
    .dm-name {
        font-size: 15px;
        font-weight: 600;
        color: var(--text-primary, #e0e0e0);
    }

    .dm-role,
    .dm-preview {
        font-size: 13px;
        color: var(--text-muted, #888);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .dm-badge {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background: var(--color-danger, #ff4136);
        color: #fff;
        font-size: 11px;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    /* Chat loading/empty states */
    .chat-loading,
    .chat-empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 60px 24px;
        color: var(--text-muted, #888);
        text-align: center;
        font-size: 14px;
    }

    .chat-empty-state span {
        font-size: 13px;
        opacity: 0.7;
    }

    /* ================================================================
       10. SIDEBAR
       ================================================================ */

    .mobile-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 700;
        opacity: 0;
        transition: opacity 0.3s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-sidebar-overlay.open {
        opacity: 1;
    }

    .mobile-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(300px, 85vw);
        background: var(--bg-secondary, #2a2a4a);
        z-index: 701;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

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

    .sidebar-header {
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
        padding-left: 16px;
        padding-right: 16px;
        padding-bottom: 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        flex-shrink: 0;
    }

    .sidebar-user-info {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .user-avatar,
    .user-avatar-lg {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--accent-primary, #007bff);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        font-weight: 600;
        color: #fff;
        flex-shrink: 0;
    }

    .avatar-placeholder {
        font-size: 18px;
        font-weight: 600;
        color: #fff;
    }

    .user-details {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .user-name {
        font-size: 15px;
        font-weight: 600;
        color: var(--text-primary, #e0e0e0);
    }

    .user-email {
        font-size: 13px;
        color: var(--text-muted, #888);
    }

    .sidebar-close-btn {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-radius: var(--radius-md, 8px);
        color: var(--text-muted, #888);
        cursor: pointer;
        flex-shrink: 0;
    }

    .sidebar-close-btn:active {
        background: var(--bg-tertiary, #3a3a5e);
    }

    .sidebar-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 0;
    }

    .sidebar-section {
        padding: 0 0 16px;
    }

    .section-title {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-muted, #888);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        padding: 8px 16px 4px;
    }

    .boards-list {
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding: 4px 8px;
    }

    .board-item,
    .sidebar-board-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
        border-radius: var(--radius-md, 8px);
        font-size: 14px;
        color: var(--text-primary, #e0e0e0);
        background: none;
        border: none;
        cursor: pointer;
        width: 100%;
        text-align: left;
        font-family: inherit;
    }

    .board-item:active,
    .sidebar-board-item:active {
        background: var(--bg-tertiary, #3a3a5e);
    }

    .board-item.active,
    .sidebar-board-item.active {
        background: rgba(0, 123, 255, 0.1);
        color: var(--accent-primary, #007bff);
    }

    .board-item-name {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar-action-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 16px;
        background: none;
        border: none;
        color: var(--accent-primary, #007bff);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        width: 100%;
        text-align: left;
        font-family: inherit;
        min-height: 44px;
    }

    .sidebar-footer {
        border-top: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        flex-shrink: 0;
    }

    .sidebar-footer-btn {
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: 14px;
        padding: 12px 16px;
        color: var(--text-primary, #e0e0e0);
        background: none;
        border: none;
        cursor: pointer;
        width: 100%;
        text-align: left;
        font-family: inherit;
        min-height: 44px;
    }

    .sidebar-footer-btn:active {
        background: var(--bg-tertiary, #3a3a5e);
    }

    /* Labels list */
    .labels-list {
        padding: 4px 8px;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .label-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 16px;
        font-size: 14px;
        color: var(--text-primary, #e0e0e0);
    }

    .label-color-dot {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    /* Team list */
    .team-list {
        padding: 4px 8px;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .team-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 16px;
    }

    .team-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: var(--bg-tertiary, #3a3a5e);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        font-weight: 600;
        color: var(--text-secondary, #cccccc);
        flex-shrink: 0;
    }

    .team-info {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .team-name {
        font-size: 14px;
        font-weight: 500;
        color: var(--text-primary, #e0e0e0);
    }

    .team-role {
        font-size: 12px;
        color: var(--text-muted, #888);
    }

    /* ================================================================
       11. NOTIFICATIONS MODAL
       ================================================================ */

    .notifications-loading {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 40px 20px;
        color: var(--text-muted, #888);
        font-size: 14px;
    }

    .notifications-list {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .notification-item {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        padding: 14px 0;
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.2));
        cursor: pointer;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }

    .notification-item:active {
        background: var(--bg-tertiary, #3a3a5e);
        border-radius: var(--radius-md, 8px);
    }

    .notification-item.unread {
        background: rgba(0, 123, 255, 0.06);
    }

    .notification-icon-wrap {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--bg-tertiary, #3a3a5e);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        color: var(--accent-primary, #007bff);
    }

    .notification-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 3px;
        min-width: 0;
    }

    .notification-text {
        font-size: 14px;
        color: var(--text-primary, #e0e0e0);
        line-height: 1.4;
    }

    .notification-card {
        font-size: 12px;
        color: var(--text-muted, #888);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .notification-time {
        font-size: 11px;
        color: var(--text-muted, #888);
    }

    .notification-unread-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--accent-primary, #007bff);
        flex-shrink: 0;
        margin-top: 4px;
    }

    .mark-all-read-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 10px 0;
        background: none;
        border: none;
        color: var(--accent-primary, #007bff);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        font-family: inherit;
        min-height: 44px;
    }

    /* ================================================================
       12. USER MENU
       ================================================================ */

    .user-menu-sheet {
        padding-bottom: 0;
    }

    /* Profile header */
    .um-profile-header {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 4px 20px 16px;
    }

    .um-avatar {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--accent-primary, #007bff) 0%, #00d4ff 100%);
        box-shadow: 0 4px 16px rgba(0, 123, 255, 0.35);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        font-weight: 800;
        color: #fff;
        flex-shrink: 0;
        letter-spacing: -0.5px;
    }

    .um-profile-info {
        display: flex;
        flex-direction: column;
        gap: 5px;
        min-width: 0;
    }

    .um-username {
        font-size: 19px;
        font-weight: 700;
        color: var(--text-primary, #e0e0e0);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .um-role-badge {
        display: inline-flex;
        align-items: center;
        padding: 3px 10px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 600;
        background: var(--bg-quaternary, #3a3a5e);
        color: var(--text-muted, #888);
        width: fit-content;
    }

    .um-role-badge.admin {
        background: rgba(0, 123, 255, 0.15);
        color: var(--accent-primary, #007bff);
    }

    /* Stats row */
    .um-stats-row {
        display: flex;
        align-items: center;
        gap: 0;
        margin: 0 16px 16px;
        padding: 12px 16px;
        background: var(--bg-tertiary, #2a2a4a);
        border-radius: var(--radius-md, 10px);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.15));
    }

    .um-stat {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        min-width: 0;
    }

    .um-stat-board {
        flex: 2;
        align-items: flex-end;
    }

    .um-stat-value {
        font-size: 18px;
        font-weight: 700;
        color: var(--text-primary, #e0e0e0);
        line-height: 1;
    }

    .um-stat-board-name {
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100px;
    }

    .um-stat-label {
        font-size: 11px;
        color: var(--text-muted, #888);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .um-stat-sep {
        width: 1px;
        height: 28px;
        background: var(--accent-border, rgba(122, 158, 245, 0.2));
        flex-shrink: 0;
        margin: 0 8px;
    }

    /* Scrollable section */
    .user-menu-sheet .modal-content-scrollable {
        padding: 0 12px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    /* Section label */
    .um-section-label {
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: var(--text-muted, #888);
        padding: 8px 8px 4px;
    }

    /* Group */
    .um-group {
        background: var(--bg-tertiary, #2a2a4a);
        border-radius: var(--radius-md, 12px);
        border: 1px solid var(--accent-border, rgba(122, 158, 245, 0.12));
        overflow: hidden;
        margin-bottom: 8px;
    }

    .um-group-danger {
        background: rgba(255, 65, 54, 0.06);
        border-color: rgba(255, 65, 54, 0.15);
    }

    /* Item */
    .um-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 0 14px;
        min-height: 52px;
        background: none;
        border: none;
        border-bottom: 1px solid var(--accent-border, rgba(122, 158, 245, 0.08));
        color: var(--text-primary, #e0e0e0);
        font-size: 15px;
        font-weight: 500;
        cursor: pointer;
        width: 100%;
        text-align: left;
        font-family: inherit;
        transition: background 0.12s;
        -webkit-tap-highlight-color: transparent;
    }

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

    .um-item:active {
        background: rgba(255, 255, 255, 0.05);
    }

    .um-item.active {
        color: var(--accent-primary, #007bff);
    }

    .um-item-danger {
        color: var(--color-danger, #ff4136);
    }

    /* Item icon */
    .um-item-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        background: var(--bg-quaternary, #3a3a5e);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        color: var(--text-secondary, #ccc);
    }

    .um-item.active .um-item-icon {
        background: rgba(0, 123, 255, 0.15);
        color: var(--accent-primary, #007bff);
    }

    .um-item-icon-admin {
        background: rgba(0, 123, 255, 0.12);
        color: var(--accent-primary, #007bff);
    }

    .um-item-danger .um-item-icon {
        background: rgba(255, 65, 54, 0.12);
        color: var(--color-danger, #ff4136);
    }

    /* Item label */
    .um-item-label {
        flex: 1;
    }

    /* Item right side */
    .um-item-right {
        display: flex;
        align-items: center;
        gap: 6px;
        color: var(--text-muted, #888);
        margin-left: auto;
        flex-shrink: 0;
    }

    /* Badge */
    .um-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        background: var(--color-danger, #ff4136);
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        border-radius: 10px;
    }

    /* Active dot */
    .um-active-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--accent-primary, #007bff);
    }

    /* Theme toggle */
    .um-toggle {
        width: 44px;
        height: 26px;
        border-radius: 13px;
        background: var(--bg-quaternary, #3a3a5e);
        position: relative;
        transition: background 0.2s;
        flex-shrink: 0;
    }

    .um-toggle.on {
        background: var(--accent-primary, #007bff);
    }

    .um-toggle-thumb {
        position: absolute;
        top: 3px;
        left: 3px;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0,0,0,0.3);
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .um-toggle.on .um-toggle-thumb {
        transform: translateX(18px);
    }

    /* Legacy classes kept for other menus */
    .user-menu-items { display: flex; flex-direction: column; gap: 2px; }
    .user-menu-item {
        display: flex; align-items: center; gap: 12px;
        padding: 14px 12px; border-radius: var(--radius-md, 8px);
        min-height: 52px; background: none; border: none;
        color: var(--text-primary, #e0e0e0); font-size: 15px;
        font-weight: 500; cursor: pointer; width: 100%;
        text-align: left; font-family: inherit;
    }
    .user-menu-item:active { background: var(--bg-tertiary, #3a3a5e); }
    .user-menu-item.danger { color: var(--color-danger, #ff4136); }
    .user-menu-divider { height: 1px; background: var(--accent-border, rgba(122,158,245,0.2)); margin: 4px 0; }
    .menu-badge {
        display: inline-flex; align-items: center; justify-content: center;
        min-width: 22px; height: 22px; padding: 0 6px;
        background: var(--color-danger, #ff4136); color: #fff;
        font-size: 12px; font-weight: 700; border-radius: 11px; margin-left: auto;
    }
    .menu-theme-indicator { margin-left: auto; font-size: 13px; color: var(--text-muted, #888); }

    .empty-list {
        padding: 12px 16px;
        color: var(--text-muted, #888);
        font-size: 14px;
    }

    /* ================================================================
       13. SHARED UTILITIES — empty states, misc
       ================================================================ */

    .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 40px 20px;
        color: var(--text-muted, #888);
        text-align: center;
        font-size: 14px;
    }

    /* Check icon in board menu */
    .check-icon {
        margin-left: auto;
        color: var(--accent-primary, #007bff);
    }
}

/* ================================================================
   WIKI MODAL — Mobile adaptation
   ================================================================ */

@media (max-width: 768px) {
    /* Full-screen modal */
    #wikiModal .wiki-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        border-radius: 0;
        transform: none;
        display: flex;
        flex-direction: column;
    }

    /* Compact header */
    #wikiModal .wiki-modal-header {
        padding: 12px 16px;
        flex-shrink: 0;
    }

    #wikiModal .wiki-modal-header h3 {
        font-size: 16px;
    }

    /* Layout: column instead of row */
    #wikiModal .canvas-layout {
        flex-direction: column;
        overflow: hidden;
    }

    /* Nav becomes horizontal tab bar */
    #wikiModal .canvas-nav {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--bg-quaternary);
        padding: 0;
        flex-direction: row;
        flex-shrink: 0;
        overflow-x: auto;
        overflow-y: hidden;
        display: flex;
        background: var(--bg-secondary);
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    #wikiModal .canvas-nav::-webkit-scrollbar {
        display: none;
    }

    /* First section (Главная + Файлы) inline */
    #wikiModal .canvas-nav-section {
        flex-direction: row;
        gap: 0;
        flex-shrink: 0;
    }

    /* Скрываем отдельную секцию страниц — они в дропдауне */
    #wikiModal #wikiPagesSection {
        display: none !important;
    }

    /* Показываем chevron только на мобильном */
    #wikiModal .wiki-page-chevron {
        display: block;
        margin-left: 2px;
        transition: transform 0.2s ease;
        flex-shrink: 0;
    }

    #wikiModal #wikiMainNavItem.dropdown-open .wiki-page-chevron {
        transform: rotate(180deg);
    }

    /* Позиционирование nav для дропдауна */
    #wikiModal .canvas-nav {
        position: relative;
    }

    /* Дропдаун страниц */
    #wikiModal .wiki-page-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 200px;
        background: var(--bg-secondary);
        border: 1px solid var(--bg-quaternary);
        border-radius: 0 0 var(--radius-md) var(--radius-md);
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
        z-index: 100;
        overflow: hidden;
    }

    #wikiModal .wiki-page-dropdown-list {
        display: flex;
        flex-direction: column;
        padding: 4px;
    }

    #wikiModal .wiki-dropdown-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
        border-radius: var(--radius-sm);
        color: var(--text-secondary);
        font-size: 14px;
        cursor: pointer;
        transition: background 0.15s;
    }

    #wikiModal .wiki-dropdown-item:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
    }

    #wikiModal .wiki-dropdown-item.active {
        color: var(--accent-primary);
        font-weight: 500;
    }

    #wikiModal .wiki-dropdown-add {
        border-top: 1px solid var(--bg-quaternary);
        margin-top: 4px;
        color: var(--text-muted);
    }

    /* Nav items: horizontal pill tabs */
    #wikiModal .canvas-nav-item {
        padding: 10px 14px;
        border-radius: 0;
        white-space: nowrap;
        font-size: 13px;
        flex-shrink: 0;
        border-bottom: 2px solid transparent;
        gap: 6px;
    }

    #wikiModal .canvas-nav-item svg {
        width: 16px;
        height: 16px;
    }

    #wikiModal .canvas-nav-item.active {
        background: transparent;
        color: var(--accent-primary);
        border-bottom-color: var(--accent-primary);
        font-weight: 600;
    }

    #wikiModal .canvas-nav-item:hover {
        background: var(--bg-tertiary);
    }

    /* Page items in tab bar */
    #wikiModal .canvas-page-item {
        padding: 10px 14px;
        border-radius: 0;
        white-space: nowrap;
        font-size: 13px;
        flex-shrink: 0;
        border-bottom: 2px solid transparent;
        gap: 6px;
    }

    #wikiModal .canvas-page-item.active {
        background: transparent;
        color: var(--accent-primary);
        border-bottom-color: var(--accent-primary);
        font-weight: 600;
    }

    /* Always show delete btn on mobile */
    #wikiModal .canvas-page-item .page-delete-btn {
        opacity: 1;
        width: 16px;
        height: 16px;
    }

    /* Add page button in tab bar */
    #wikiModal .canvas-nav-add-btn {
        width: 28px;
        height: 28px;
        flex-shrink: 0;
    }

    /* Main content: fill remaining space */
    #wikiModal .canvas-main {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    #wikiModal .wiki-view-mode,
    #wikiModal .wiki-edit-mode,
    #wikiModal .wiki-files-mode {
        padding: 16px;
        height: auto;
        min-height: 200px;
    }

    /* EasyMDE editor на мобильном */
    #wikiModal .wiki-edit-mode {
        padding: 0;
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow-y: auto;  /* сам скроллится */
        min-height: 0;
    }

    #wikiModal .wiki-edit-mode .EasyMDEContainer {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    #wikiModal .wiki-edit-mode .CodeMirror {
        min-height: 200px !important;
        font-size: 15px;
        padding: 16px !important;
        padding-bottom: 16px !important;
        box-sizing: border-box;
    }

    /* Тулбар: убираем floating pill, прикрепляем к низу экрана */
    #wikiModal .editor-toolbar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: unset !important;
        transform: none !important;
        width: 100% !important;
        border-radius: 0 !important;
        border-top: 1px solid rgba(255,255,255,0.12) !important;
        border-bottom: none !important;
        border-left: none !important;
        border-right: none !important;
        padding: 8px 12px !important;
        flex-wrap: wrap;
        gap: 2px;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.4) !important;
        z-index: 700 !important;
        opacity: 1 !important;
        justify-content: center;
    }

    #wikiModal .editor-toolbar:hover {
        bottom: 0 !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.4) !important;
    }

    #wikiModal .editor-toolbar a {
        width: 52px !important;
        height: 52px !important;
        min-width: 52px !important;
        min-height: 52px !important;
        font-size: 20px !important;
    }

    /* Отступ снизу у редактора чтобы тулбар не перекрывал текст */
    #wikiModal .wiki-edit-mode .CodeMirror,
    #wikiModal .wiki-edit-mode .EasyMDEContainer {
        padding-bottom: 80px !important;
    }
}

/* ================================================================
   ANIMATIONS — outside media query so they can be referenced
   ================================================================ */

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

/* ================================================================
   MOBILE DIALOGS — Toast & Confirm
   ================================================================ */

.mobile-toast {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + 80px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-secondary, #2a2a2a);
    color: var(--text-primary, #fff);
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 10000;
    max-width: calc(100vw - 32px);
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-toast.mobile-toast-error {
    border-left: 3px solid var(--danger, #e74c3c);
}

.mobile-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.mobile-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    transition: background 0.25s;
}

.mobile-confirm-overlay.visible {
    background: rgba(0,0,0,0.5);
}

.mobile-confirm-sheet {
    width: 100%;
    background: var(--bg-primary, #1a1a2e);
    border-radius: 20px 20px 0 0;
    padding: 24px 16px calc(16px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.mobile-confirm-overlay.visible .mobile-confirm-sheet {
    transform: translateY(0);
}

.mobile-confirm-message {
    font-size: 16px;
    color: var(--text-primary, #fff);
    text-align: center;
    padding: 0 8px 20px;
    line-height: 1.5;
}

.mobile-confirm-actions {
    display: flex;
    gap: 10px;
}

.mobile-confirm-btn {
    flex: 1;
    height: 48px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.mobile-confirm-btn:active { opacity: 0.7; }

.mobile-confirm-btn.cancel {
    background: var(--bg-secondary, #2a2a2a);
    color: var(--text-secondary, #aaa);
}

.mobile-confirm-btn.danger {
    background: var(--danger, #e74c3c);
    color: #fff;
}

.mobile-confirm-btn.primary {
    background: var(--accent, #6c63ff);
    color: #fff;
}

/* ================================================================
   9. FILTERS MODAL & CHIPS
   ================================================================ */
.filter-section {
    margin-bottom: 24px;
}

.filter-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.filter-chip {
    padding: 8px 16px;
    border-radius: 100px;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-border);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.filter-chip.active {
    background: var(--accent-primary);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.filter-chip[style*="--tag-color"] {
    border-left: 4px solid var(--tag-color);
}

.filter-chip.active[style*="--tag-color"] {
    background: var(--tag-color);
    color: white;
}

.priority-high.active { background: #ef4444; box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3); }
.priority-medium.active { background: #f59e0b; box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3); }
.priority-low.active { background: #10b981; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3); }

.search-input-wrapper {
    position: relative;
    margin-top: 8px;
}

.search-input-wrapper::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    pointer-events: none;
    opacity: 0.6;
}

/* ================================================================
   10. PROFILE EDIT MODAL
   ================================================================ */
.profile-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 10px;
}

.profile-avatar-edit {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-secondary, #2a2a3c);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 3px solid var(--accent, #6c63ff);
    box-shadow: 0 0 20px rgba(108, 99, 255, 0.3);
    cursor: pointer;
}

.profile-avatar-edit img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-edit .avatar-placeholder {
    font-size: 40px;
    font-weight: 700;
    color: var(--accent, #6c63ff);
}

.avatar-edit-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    background: var(--accent, #6c63ff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 2px solid var(--bg-primary, #1a1a2e);
}

.profile-avatar-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 10px;
}

.mobile-form-group {
    margin-bottom: 20px;
    padding: 0 4px;
}

.mobile-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
}

.mobile-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px 16px;
    color: white;
    font-size: 15px;
    transition: all 0.3s ease;
}

.mobile-input:focus {
    outline: none;
    border-color: var(--accent, #6c63ff);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1);
}

.mobile-input.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.profile-actions-mobile {
    padding: 10px 0;
}

.mobile-btn {
    width: 100%;
    padding: 16px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-btn.primary {
    background: var(--accent, #6c63ff);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

.mobile-btn.primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.mobile-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.profile-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 30px 0;
}

.profile-section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: white;
}

/* Style for the edit button in user menu */
.um-profile-edit-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-left: auto;
    cursor: pointer;
}

.um-profile-edit-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.9);
}

/* Common Modal Header for Bottom Sheets */
.modal-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 0 4px;
}

.modal-header-mobile h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.modal-close-mobile {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.modal-close-mobile:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.9);
}

/* ── Direct Messages / Contact List ── */
.dm-section, .dm-search-results {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    padding: 8px 0 !important;
    width: 100% !important;
    align-items: stretch !important;
}

.chat-user-item, 
.chat-user-item.dm-search-item {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 12px 16px !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 0 !important;
    transition: background 0.2s ease !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    background: transparent !important;
    text-align: left !important;
}

.chat-user-item:active {
    background: rgba(255, 255, 255, 0.1) !important;
}

.chat-user-avatar {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    border-radius: 50% !important;
    margin: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
}

.chat-user-info {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 2px !important;
    flex: 1 !important;
    min-width: 0 !important;
    text-align: left !important;
    margin: 0 !important;
}

.chat-user-name {
    font-size: 15px !important;
    font-weight: 600 !important;
    margin: 0 !important;
    color: var(--text-primary) !important;
    display: block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
}

.chat-user-last-msg {
    font-size: 12px !important;
    color: var(--text-muted) !important;
    opacity: 0.7 !important;
    display: block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
}

.dm-search-results {
    max-height: none !important;
}

.dm-search-wrap {
    margin: 8px 16px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    padding: 8px 12px !important;
}

.dm-search-input {
    background: transparent !important;
    border: none !important;
    color: white !important;
    width: 100% !important;
    font-size: 14px !important;
    padding: 4px 0 !important;
}

.chat-user-badge {
    margin-left: auto !important;
    flex-shrink: 0 !important;
}

.dm-open-icon {
    opacity: 0.4 !important;
    margin-left: 8px !important;
    flex-shrink: 0 !important;
}
}
