/* Основные стили из шаблона - полная версия */
:root {
    --primary: #0088cc;
    --primary-dark: #0077b3;
    --primary-light: #00a8ff;
    --premium: #ffd700;
    --premium-dark: #e6c200;
    --accent: #ff9500;
    --danger: #ff3b30;
    --success: #34c759;
    --bg-dark: #0a0a0a;
    --bg-darker: #050505;
    --bg-sidebar: #111b21;
    --bg-chat: #0b141a;
    --bg-input: #1e2a35;
    --bg-message-out: #005c4b;
    --bg-message-in: #202c33;
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-active: rgba(255, 255, 255, 0.08);
    --bg-story: rgba(0, 0, 0, 0.5);
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --text-muted: #6b7b84;
    --border: #2a3942;
    --border-light: #3d4a54;
    --online: #00c853;
    --offline: #8696a0;
    --unread-badge: #25d366;
    --typing-indicator: #0088cc;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    --shadow-heavy: 0 5px 20px rgba(0, 0, 0, 0.7);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-full: 50%;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-light));
    --gradient-premium: linear-gradient(135deg, var(--premium), #ffed4e);
    --gradient-story: linear-gradient(45deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    font-size: clamp(13px, 2vw, 16px);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    touch-action: pan-y;
}

/* Специальные стили для страниц с прокруткой */
body.profile-page,
body.admin-page,
body.create-page {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: auto;
    min-height: 100vh;
    display: block;
}

body.main-page {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.main-page .main-container {
    overflow: hidden;
    flex: 1;
    display: flex;
}

/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Модалка создания истории (по умолчанию скрыта) */
.create-story-modal {
    display: none;
    z-index: 5200;
}

.create-story-modal.active {
    display: flex;
}

/* Жёстко фиксируем поведение конкретной модалки создания истории */
#createStoryModal {
    display: none !important;
    opacity: 0;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    transition: opacity 0.18s ease;
}

#createStoryModal.active {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
}

#createStoryModal .modal-content {
    width: min(92vw, 520px);
    max-height: min(82vh, 720px);
    border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(180deg, rgba(17,27,33,0.96), rgba(17,27,33,0.90));
}

#createStoryModal .modal-header {
    position: sticky;
    top: 0;
    background: rgba(17,27,33,0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 2;
}

#createStoryModal .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

#createStoryModal textarea,
#createStoryModal input[type="file"],
#createStoryModal input[type="color"] {
    outline: none;
}

#createStoryModal textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 12px;
    border-radius: var(--radius-md);
}

#createStoryModal input[type="file"] {
    width: 100%;
    background: var(--bg-input);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-md);
    padding: 12px;
    color: var(--text-secondary);
}

#createStoryModal input[type="file"]::file-selector-button {
    background: var(--gradient-primary);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    margin-right: 10px;
}

#createStoryModal .btn.btn-primary {
    border-radius: 14px;
    padding: 12px 14px;
    font-weight: 700;
}

.modal-content {
    background: var(--bg-sidebar);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-heavy);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.user-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.user-item:hover {
    background: var(--bg-hover);
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-status {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Единый Header */
.main-header {
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2000;
    backdrop-filter: blur(20px) saturate(180%);
    background-color: rgba(17, 27, 33, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(12px, 2vw, 20px);
    height: clamp(56px, 10vh, 64px);
    min-height: 56px;
    gap: 16px;
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: clamp(8px, 1.5vw, 12px);
}

.header-left {
    flex: 0 0 auto;
}

.header-center {
    flex: 1;
    justify-content: center;
}

.header-right {
    flex: 0 0 auto;
}

.header-btn {
    width: clamp(36px, 8vw, 44px);
    height: clamp(36px, 8vw, 44px);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    border: none;
    color: var(--text-primary);
    position: relative;
    flex-shrink: 0;
    touch-action: manipulation;
}

.header-btn:hover {
    background-color: var(--bg-hover);
    transform: scale(1.05);
}

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

.header-btn.premium {
    background: var(--gradient-premium);
    color: #000;
}

.header-btn.premium:hover {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.header-btn i {
    font-size: clamp(16px, 4vw, 18px);
}

.header-user {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 4px;
    border-radius: var(--radius-full);
}

.header-user:hover {
    background-color: var(--bg-hover);
}

.header-avatar {
    width: clamp(36px, 8vw, 44px);
    height: clamp(36px, 8vw, 44px);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: clamp(14px, 3.5vw, 16px);
    overflow: hidden;
    border: 2px solid var(--border);
    transition: var(--transition);
}

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

.header-balance {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(0, 136, 204, 0.1);
    border: 1px solid rgba(0, 136, 204, 0.22);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: var(--transition);
    flex-shrink: 0;
    line-height: 1;
}

.header-balance:hover {
    background: rgba(0, 136, 204, 0.16);
    border-color: rgba(0, 136, 204, 0.4);
    color: var(--text-primary);
}

.header-balance i {
    color: var(--primary);
    font-size: 11px;
}

.header-pro-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--gradient-premium);
    color: #000;
    text-decoration: none;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.header-back-btn {
    text-decoration: none;
    color: var(--text-primary);
}

.header-page-title {
    font-size: clamp(15px, 4vw, 17px);
    font-weight: 600;
}

.app-header .logo {
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.app-header .logo-text {
    display: block;
    font-weight: 700;
    font-size: clamp(15px, 4vw, 18px);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(42vw, 220px);
}

.app-header .logo-text--title {
    color: var(--text-primary);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: currentColor;
}

.app-header .logo-text--brand {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@media (max-width: 768px) {
    .app-header .logo-text--brand {
        background: none;
        -webkit-background-clip: unset;
        background-clip: unset;
        -webkit-text-fill-color: currentColor;
        color: var(--text-primary);
    }
}

.chat-back-btn {
    display: none;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: var(--radius-full);
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 2px;
}

.chat-back-btn:hover {
    background: var(--bg-hover);
}

.header-user:hover .header-avatar {
    border-color: var(--primary);
    transform: scale(1.1);
}

/* Совместимость со старыми классами */
.navbar {
    display: none;
}

.navbar-item {
    display: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 12px);
    cursor: pointer;
    padding: 0;
    flex-shrink: 1;
    min-width: 0;
}

.logo-icon {
    width: clamp(32px, 7vw, 40px);
    height: clamp(32px, 7vw, 40px);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    color: white;
    font-size: clamp(16px, 4vw, 20px);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.logo-text {
    font-weight: 800;
    font-size: clamp(18px, 4.5vw, 22px);
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: none;
}

/* Старый .logo-text — только вне app-header на десктопе */
@media (min-width: 769px) {
    .logo-text:not(.logo-text--title):not(.logo-text--brand) {
        display: block;
    }
}

/* Истории */
.stories-container {
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    padding: clamp(12px, 3vh, 16px) clamp(12px, 3vw, 16px);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
    display: none;
}

.stories-container.active {
    display: block;
}

.stories-container::-webkit-scrollbar {
    display: none;
}

.stories-title {
    font-weight: 600;
    font-size: clamp(14px, 3.5vw, 16px);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stories-scroll {
    display: flex;
    gap: 12px;
    padding-bottom: 4px;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    width: clamp(52px, 12vw, 64px);
}

.story-item:hover {
    transform: translateY(-2px);
}

.story-avatar {
    position: relative;
    width: clamp(44px, 10vw, 56px);
    height: clamp(44px, 10vw, 56px);
}

.story-ring {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: var(--radius-full);
    background: var(--gradient-story);
    padding: 2px;
}

.story-ring.seen {
    background: var(--border);
}

.story-ring.premium::after {
    content: "⭐";
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 12px;
    background: var(--gradient-premium);
    border-radius: var(--radius-full);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.story-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: clamp(16px, 4vw, 20px);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.story-add {
    border: 2px dashed var(--border-light);
    background: rgba(255, 255, 255, 0.05);
}

.story-add i {
    font-size: 20px;
    color: var(--text-secondary);
}

.story-name {
    font-size: clamp(10px, 2.5vw, 11px);
    color: var(--text-secondary);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Основной контейнер */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

/* Боковая панель */
.sidebar {
    width: 100%;
    max-width: min(400px, 90vw);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1900;
    box-shadow: var(--shadow-heavy);
    will-change: transform;
}

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

@media (min-width: 769px) {
    .sidebar {
        position: relative;
        box-shadow: none;
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        max-width: 100%;
        transform: translateX(-100%);
    }
    
    .stories-container {
        display: block;
    }
}

.sidebar-header {
    padding: clamp(16px, 4vh, 20px) clamp(12px, 3vw, 16px);
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: clamp(16px, 4vw, 18px);
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.tab {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tab i {
    font-size: 14px;
    flex-shrink: 0;
}

.tab span {
    display: inline-block;
}

@media (max-width: 768px) {
    .tab span {
        display: none;
    }
    
    .tab {
        padding: 8px 12px;
        min-width: 44px;
        justify-content: center;
    }
}

.tab.active {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

.tab:hover {
    background-color: var(--bg-hover);
}

/* Список чатов */
.chat-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-list::-webkit-scrollbar {
    width: 4px;
}

.chat-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 2px;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: clamp(10px, 2.5vh, 12px) clamp(12px, 3vw, 16px);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    position: relative;
    min-height: 68px;
}

.chat-item:hover {
    background-color: var(--bg-hover);
}

.chat-item.active {
    background-color: var(--bg-active);
}

.chat-avatar {
    position: relative;
    margin-right: 12px;
    flex-shrink: 0;
}

.avatar-img {
    width: clamp(40px, 10vw, 52px);
    height: clamp(40px, 10vw, 52px);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 4vw, 18px);
    font-weight: 700;
    color: white;
    background: var(--gradient-primary);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.avatar-img.premium::after {
    content: "⭐";
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 12px;
    background: var(--gradient-premium);
    color: #000;
    border-radius: var(--radius-full);
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.avatar-status {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    background-color: var(--online);
    border: 2px solid var(--bg-sidebar);
    bottom: 2px;
    right: 2px;
    z-index: 2;
}

.avatar-status.offline {
    background-color: var(--offline);
}

.chat-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.chat-name {
    font-weight: 600;
    font-size: clamp(14px, 3.5vw, 16px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-time {
    color: var(--text-secondary);
    font-size: 11px;
    white-space: nowrap;
    margin-left: 8px;
    flex-shrink: 0;
}

.chat-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-last-message {
    color: var(--text-secondary);
    font-size: clamp(12px, 3vw, 13px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-last-message i {
    margin-right: 4px;
    font-size: 11px;
}

.unread-badge {
    background: var(--unread-badge);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
}

.pinned-indicator {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 40%;
    background-color: var(--accent);
    border-radius: 0 2px 2px 0;
}

/* Область чата */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-chat);
    position: relative;
    overflow: hidden;
    width: 100%;
}

.chat-header-area {
    background-color: var(--bg-sidebar);
    padding: 0 clamp(12px, 3vw, 16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: clamp(56px, 10vh, 64px);
    min-height: 56px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1800;
    backdrop-filter: blur(20px);
    background-color: rgba(17, 27, 33, 0.95);
}

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

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

.chat-contact-name {
    font-weight: 600;
    font-size: clamp(15px, 4vw, 17px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-contact-status {
    color: var(--text-secondary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.typing-indicator {
    color: var(--typing-indicator);
    font-weight: 500;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    height: 10px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: var(--radius-full);
    background-color: var(--typing-indicator);
    margin-right: 2px;
    animation: typing 1.5s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* Сообщения */
.chat-messages {
    flex: 1;
    min-height: 0;
    padding: clamp(16px, 4vh, 20px) clamp(12px, 3vw, 16px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 2px;
}

.message {
    max-width: min(85%, 600px);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    position: relative;
    word-wrap: break-word;
    animation: messageAppear 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: var(--transition);
}

@media (max-width: 768px) {
    .message {
        max-width: 90%;
    }
}

@keyframes messageAppear {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message-out {
    align-self: flex-end;
    background: var(--bg-message-out);
    border-bottom-right-radius: 4px;
}

.message-in {
    align-self: flex-start;
    background: var(--bg-message-in);
    border-bottom-left-radius: 4px;
}

.message-premium {
    border: 1px solid rgba(255, 215, 0, 0.3);
    background: linear-gradient(135deg, rgba(0, 92, 75, 0.9), rgba(0, 92, 75, 0.7));
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
    margin-bottom: 4px;
    word-break: break-word;
}

.message-time {
    text-align: right;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.message-in .message-time {
    color: rgba(255, 255, 255, 0.5);
}

.message-check {
    color: #8fd6ff;
    font-size: 10px;
}

.message-check.double {
    color: #53d769;
}

.message-reply {
    border-left: 3px solid var(--primary);
    padding: 6px 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.message-out .message-reply {
    border-left-color: rgba(255, 255, 255, 0.6);
}

.message-reply-author {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-light);
    margin-bottom: 2px;
}

.message-out .message-reply-author {
    color: rgba(255, 255, 255, 0.9);
}

.message-reply-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.message-media-link {
    display: block;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.message-image {
    display: block;
    max-width: min(280px, 70vw);
    max-height: 320px;
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.message-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
    font-size: 13px;
}

.message-file:hover {
    background: rgba(0, 0, 0, 0.3);
}

.message-highlight {
    animation: messageHighlight 1.2s ease;
}

@keyframes messageHighlight {
    0%, 100% { box-shadow: none; }
    30% { box-shadow: 0 0 0 2px var(--primary); }
}

.reply-bar,
.attach-preview {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-input);
    border-top: 1px solid var(--border);
}

.reply-bar-content {
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.reply-bar-line {
    width: 3px;
    border-radius: 2px;
    background: var(--primary);
    flex-shrink: 0;
}

.reply-bar-text {
    min-width: 0;
    flex: 1;
}

.reply-bar-author {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-light);
}

.reply-bar-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-bar-close,
.attach-preview-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.attach-preview img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.attach-preview-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-input-stack {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    background: var(--bg-sidebar);
}

.chat-input-stack .chat-input-area {
    border-top: none;
}

.chat-input-stack .reply-bar,
.chat-input-stack .attach-preview {
    border-top: 1px solid var(--border);
}

.chat-active {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 768px) {
    .message {
        padding: 8px 12px;
        max-width: 92%;
    }

    .message-image {
        max-width: 100%;
        max-height: 260px;
    }

    .message-text {
        font-size: 14px;
    }
}
.chat-input-area {
    padding: clamp(12px, 3vh, 16px) clamp(12px, 3vw, 16px);
    background-color: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    gap: clamp(8px, 2vw, 12px);
    position: sticky;
    bottom: 0;
    z-index: 1800;
}

.chat-input-container {
    flex: 1;
    background-color: var(--bg-input);
    border-radius: var(--radius-xl);
    padding: clamp(10px, 2.5vh, 12px) clamp(12px, 3vw, 16px);
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 12px);
    transition: var(--transition);
    border: 1px solid transparent;
    min-height: 52px;
}

.chat-input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 136, 204, 0.2);
}

.input-action {
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    width: clamp(32px, 7vw, 36px);
    height: clamp(32px, 7vw, 36px);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent;
    border: none;
}

.input-action:hover {
    color: var(--primary);
    background-color: var(--bg-hover);
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
    min-height: 22px;
}

.chat-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    width: 100%;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    font-family: inherit;
    padding: 0;
    margin: 0;
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.send-button {
    background: var(--gradient-primary);
    width: clamp(40px, 9vw, 44px);
    height: clamp(40px, 9vw, 44px);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.4);
}

.send-button:active {
    transform: translateY(0);
}

.send-button i {
    color: white;
    font-size: clamp(16px, 4vw, 18px);
}

.send-button.disabled {
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.send-button.disabled:hover {
    transform: none;
    box-shadow: var(--shadow);
}

/* Заглушка чата */
.chat-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: clamp(20px, 5vh, 40px) clamp(16px, 4vw, 20px);
    color: var(--text-secondary);
    background: radial-gradient(circle at 30% 30%, rgba(17, 27, 33, 0.5) 0%, transparent 70%);
}

.chat-placeholder-icon {
    font-size: clamp(60px, 15vw, 80px);
    margin-bottom: clamp(16px, 4vh, 24px);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.chat-placeholder h2 {
    font-size: clamp(22px, 5.5vw, 28px);
    margin-bottom: clamp(8px, 2vh, 12px);
    color: var(--text-primary);
    font-weight: 700;
}

.chat-placeholder p {
    max-width: min(400px, 90vw);
    line-height: 1.5;
    font-size: clamp(14px, 3.5vw, 15px);
    opacity: 0.8;
    margin-bottom: 8px;
}

/* Контекстное меню */
.context-menu {
    position: fixed;
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-heavy);
    z-index: 3000;
    min-width: 180px;
    overflow: hidden;
    border: 1px solid var(--border);
    display: none;
}

.context-menu.active {
    display: block;
}

.context-menu-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 14px;
}

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

.context-menu-item:hover {
    background-color: var(--bg-hover);
}

.context-menu-item i {
    width: 20px;
    text-align: center;
    color: var(--primary);
}

.context-menu-item.premium i {
    color: var(--premium);
}

/* Панель эмодзи (улучшенная как в Telegram) */
.emoji-panel {
    position: absolute;
    bottom: 80px;
    left: 8px;
    right: 8px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-heavy);
    z-index: 2800;
    padding: 12px;
    display: none;
    flex-direction: column;
    border: 1px solid var(--border);
    max-height: min(400px, 50vh);
    backdrop-filter: blur(20px);
}

.emoji-panel.active {
    display: flex;
}

.emoji-categories {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    -webkit-overflow-scrolling: touch;
}

.emoji-categories::-webkit-scrollbar {
    height: 4px;
}

.emoji-categories::-webkit-scrollbar-track {
    background: transparent;
}

.emoji-categories::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.emoji-category {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 20px;
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    touch-action: manipulation;
}

.emoji-category:hover {
    background-color: var(--bg-hover);
}

.emoji-category.active {
    background-color: var(--bg-active);
    color: var(--primary);
}

.emoji-category i {
    font-size: 18px;
    color: var(--text-secondary);
}

.emoji-category.active i {
    color: var(--primary);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    overflow-y: auto;
    flex: 1;
    padding: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    -webkit-overflow-scrolling: touch;
}

.emoji-grid::-webkit-scrollbar {
    width: 4px;
}

.emoji-grid::-webkit-scrollbar-track {
    background: transparent;
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

@media (max-width: 480px) {
    .emoji-grid {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .emoji-panel {
        left: 4px;
        right: 4px;
        max-height: min(350px, 45vh);
    }
}

@media (max-width: 360px) {
    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

.emoji {
    font-size: 28px;
    text-align: center;
    padding: 8px;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.emoji:hover,
.emoji:active {
    background-color: var(--bg-hover);
    transform: scale(1.15);
}

.emoji:active {
    transform: scale(0.95);
}

/* Модальное окно истории */
.story-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 4000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.story-modal.active {
    display: flex;
    opacity: 1;
}

.story-content {
    width: min(90vw, 400px);
    height: min(70vh, 700px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    background: var(--gradient-story);
}

.story-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
    z-index: 2;
}

.story-user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}

.story-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.story-user-name {
    font-weight: 600;
    font-size: 16px;
}

.story-user-time {
    font-size: 12px;
    opacity: 0.8;
}

.story-close {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: var(--radius-full);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.story-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.story-body {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px 20px;
}

.story-media {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.story-text {
    font-size: 24px;
    color: white;
    text-align: center;
    padding: 20px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

/* Текст поверх медиа */
#storyText {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    background: rgba(0, 0, 0, 0.35);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    text-align: center;
}

.story-progress {
    position: absolute;
    top: 12px;
    left: 16px;
    right: 16px;
    display: flex;
    gap: 4px;
    z-index: 3;
}

.story-progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.story-progress-fill {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.1s linear;
}

/* PRO аккаунт */
.pro-badge {
    background: var(--gradient-premium);
    color: #000;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.pro-feature {
    position: relative;
}

.pro-feature::after {
    content: "PRO";
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--gradient-premium);
    color: #000;
    font-size: 8px;
    font-weight: 900;
    padding: 1px 4px;
    border-radius: 4px;
}

/* Премиум панель */
.premium-panel {
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 16px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.premium-panel--promo {
    padding: 14px 16px;
    margin: 10px 12px;
    cursor: default;
}

.premium-panel.is-hidden {
    display: none;
}

.premium-panel-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border: none;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

.premium-panel-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.premium-panel-cta {
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-premium);
    color: #000;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.premium-features--compact {
    gap: 8px;
}

.premium-features--compact .premium-feature {
    font-size: 13px;
}

.premium-panel--promo .premium-title {
    margin-bottom: 10px;
    padding-right: 28px;
}

.premium-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-premium);
}

.premium-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.premium-title i {
    font-size: 24px;
    background: var(--gradient-premium);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.premium-features {
    display: grid;
    gap: 12px;
}

.premium-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.premium-feature i {
    color: var(--premium);
}

/* Уведомления */
.notification {
    position: fixed;
    top: 80px;
    right: 16px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-heavy);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 3000;
    transform: translateX(150%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: min(300px, 90vw);
    border-left: 4px solid var(--primary);
}

.notification.show {
    transform: translateX(0);
}

.notification-premium {
    border-left-color: var(--premium);
}

.notification-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.notification-icon.premium {
    background: var(--gradient-premium);
    color: #000;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
}

.notification-message {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Анимации */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Оптимизация для очень медленных устройств */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Улучшенный фокус для доступности */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Стиль для выделенного текста */
::selection {
    background-color: rgba(0, 136, 204, 0.3);
    color: white;
}

/* Мобильное меню */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
    display: none;
}

.mobile-menu.active {
    display: block;
}

.mobile-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.mobile-menu-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(85vw, 320px);
    background: var(--bg-sidebar);
    box-shadow: var(--shadow-heavy);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
    pointer-events: auto;
}

.mobile-menu.active .mobile-menu-content {
    transform: translateX(0);
}

.mobile-menu-header {
    padding: clamp(16px, 4vh, 20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.mobile-menu-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: var(--transition);
}

.mobile-menu-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mobile-menu-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.mobile-menu-item:hover {
    background: var(--bg-hover);
}

.mobile-menu-item i {
    width: 24px;
    text-align: center;
    font-size: 20px;
    color: var(--primary);
}

.mobile-menu-item span {
    font-size: 16px;
    font-weight: 500;
}

/* Улучшенные стили для аватаров с изображениями */
.avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

/* Улучшенные стили для чатов */
.chat-item {
    position: relative;
}

.chat-item .chat-type-icon {
    display: none;
}

.chat-avatar .chat-type-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: var(--bg-sidebar);
    border: 2px solid var(--bg-sidebar);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    line-height: 1;
    z-index: 3;
    pointer-events: none;
    transform: translate(15%, 15%);
}

.chat-type-badge--group {
    color: var(--primary);
}

.chat-type-badge--channel {
    color: var(--accent);
}

/* Улучшенные стили для групп и каналов */
.chat-item[data-chat-type="group"] .chat-type-icon {
    color: var(--primary);
}

.chat-item[data-chat-type="channel"] .chat-type-icon {
    color: var(--accent);
}

/* Анимации для улучшения UX */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

.mobile-menu.active .mobile-menu-content {
    animation: slideInRight 0.3s ease-out;
}

/* Улучшенные стили для форм */
.form-group input:invalid {
    border-color: var(--danger);
}

.form-group input:valid {
    border-color: var(--success);
}

/* Улучшенные стили для кнопок */
.btn-group {
    display: flex;
    gap: 8px;
}

.btn-group .btn {
    flex: 1;
}

/* Индикатор загрузки */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Улучшенные стили для историй */
.story-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
}

/* Улучшенные стили для username */
.username-display {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: normal;
    margin-left: 6px;
}

/* Улучшенные стили для баланса */
.balance-display {
    font-size: clamp(24px, 6vw, 32px);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Улучшенные стили для тарифов */
.plan-card {
    transition: var(--transition);
    cursor: pointer;
}

.plan-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-heavy);
    border-color: var(--primary);
}

/* Поиск */
.search-container {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    border: 1px solid var(--border);
}

.search-box i {
    color: var(--text-secondary);
    font-size: 16px;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.search-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.search-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 8px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
}

.search-result-item:hover {
    background: var(--bg-hover);
}

.search-result-info {
    flex: 1;
}

.search-result-name {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.search-result-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* Улучшенные стили для sidebar toggle */
.sidebar-toggle {
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: transparent;
    color: var(--text-primary);
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

.sidebar-toggle.active {
    background: var(--bg-active);
}

/* Улучшенные стили для главной страницы */
.main-container {
    position: relative;
}

.sidebar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--bg-hover);
    border: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
}

.sidebar-close-btn:hover {
    background: var(--bg-active);
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: -1;
    }
    
    .sidebar-close-btn {
        display: flex !important;
    }
}


/* Улучшенные стили для чатов */
.chat-item {
    transition: var(--transition);
    position: relative;
}

.chat-item:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
}

.chat-item.active {
    background: var(--bg-active);
    border-left: 3px solid var(--primary);
}

/* Улучшенные стили для сообщений */
.message {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Исправления для мобильных устройств */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Улучшенная обработка касаний */
button,
.btn,
.navbar-item,
.chat-item,
.admin-nav-item,
.mobile-menu-item,
.bottom-nav-item,
.emoji,
.emoji-category {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

/* Исправление z-index для мобильных */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        z-index: 1000;
    }
    
    .mobile-menu {
        z-index: 5000;
    }
    
    .sidebar {
        z-index: 2000;
    }
    
    .navbar {
        z-index: 3000;
    }
    
    .emoji-panel {
        z-index: 4000;
    }
    
    .story-modal {
        z-index: 6000;
    }
    
    /* Убеждаемся что клики работают */
    .chat-item,
    .story-item,
    .user-select-item {
        pointer-events: auto;
        z-index: 1;
    }
}

/* Специальные стили для страниц с прокруткой */
body.profile-page,
body.admin-page,
body.create-page {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    height: auto !important;
    min-height: 100vh;
    display: block !important;
}

body.main-page {
    overflow: hidden !important;
    height: 100vh !important;
    height: 100dvh !important;
}

body {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
}

/* Улучшенная прокрутка */
.sidebar,
.chat-list,
.chat-messages,
.admin-content,
.admin-sidebar {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Улучшенные кнопки для мобильных */
button,
.btn,
.navbar-item,
.chat-item,
.admin-nav-item {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Адаптивные улучшения */
@media (max-width: 480px) {
    .mobile-menu-content {
        width: 85vw;
    }
    
    .navbar-right .navbar-item:nth-child(n+4) {
        display: none;
    }
    
    /* Улучшенная прокрутка на мобильных */
    .main-container {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        height: 100vh;
        height: 100dvh;
    }

    body.main-page:has(.chat-active) .main-container {
        overflow: hidden;
        height: 100dvh;
        max-height: 100dvh;
        padding-bottom: 0 !important;
    }
    
    .sidebar {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .chat-area {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.main-page:has(.chat-active) .chat-area {
        overflow: hidden;
        padding-bottom: 0 !important;
    }
    
    /* Улучшения для очень маленьких экранов */
    .header-center {
        gap: 4px;
    }
    
    .header-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .chat-item {
        padding: 10px 12px;
        min-height: 60px;
    }
    
    .avatar-img {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
}

@media (max-width: 360px) {
    .mobile-menu-content {
        width: 90vw;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    /* Дополнительные улучшения для очень маленьких экранов */
    .header-center {
        gap: 2px;
    }
    
    .header-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
    
    .header-btn i {
        font-size: 14px;
    }
    
    .chat-item {
        padding: 8px 10px;
        min-height: 56px;
    }
    
    .avatar-img {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .chat-name {
        font-size: 14px;
    }
    
    .chat-last-message {
        font-size: 12px;
    }
}

/* Нижнее мобильное меню (как в Telegram) */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    display: none;
    z-index: 2500;
    padding: 4px 2px max(4px, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    touch-action: manipulation;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: stretch;
    }
    
    .main-container {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }
    
    .chat-area {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }
    
    .header-desktop-only,
    .header-center {
        display: none !important;
    }
    
    .header-content {
        height: 48px;
        min-height: 48px;
        padding: 0 10px;
        gap: 8px;
    }

    .header-left {
        flex: 1;
        min-width: 0;
    }

    .header-right {
        flex-shrink: 0;
    }
    
    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .header-back-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .header-balance {
        height: 28px;
        padding: 0 8px;
        font-size: 11px;
        gap: 4px;
    }

    .header-balance i {
        font-size: 10px;
    }
    
    .chat-area:has(.chat-placeholder) {
        display: none;
    }
    
    .sidebar {
        z-index: 2000;
    }
    
    .main-header {
        z-index: 2100;
        display: block !important;
    }
    
    body.main-page:has(.chat-active) .main-header,
    body.main-page:has(.chat-active) .stories-container,
    body.main-page:has(.chat-active) .mobile-bottom-nav {
        display: none !important;
    }

    body.main-page:has(.chat-active) .main-container {
        padding-bottom: 0 !important;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }

    body.main-page:has(.chat-active) .chat-area {
        padding-bottom: 0 !important;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    body.main-page:has(.chat-active) .chat-active {
        height: 100%;
        min-height: 0;
    }

    body.main-page:has(.chat-active) .chat-messages {
        flex: 1;
        min-height: 0;
        padding-bottom: 8px;
    }

    body.main-page:has(.chat-active) .chat-input-stack,
    body.chat-page .chat-input-stack {
        flex-shrink: 0;
        border-top: 1px solid var(--border);
    }

    body.main-page:has(.chat-active) .chat-input-area,
    body.chat-page .chat-input-stack .chat-input-area {
        position: relative;
        bottom: auto;
        padding: 8px 10px;
        padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
        gap: 8px;
        align-items: flex-end;
    }

    body.main-page:has(.chat-active) .chat-input-container,
    body.chat-page .chat-input-container {
        min-height: 40px !important;
        padding: 6px 10px;
        gap: 6px;
        min-width: 0;
    }

    body.main-page:has(.chat-active) .chat-input-area .input-action,
    body.main-page:has(.chat-active) .chat-input-area .send-button,
    body.chat-page .chat-input-area .input-action,
    body.chat-page .chat-input-area .send-button {
        min-width: 36px !important;
        min-height: 36px !important;
        width: 36px;
        height: 36px;
    }

    body.main-page:has(.chat-active) #voiceBtn,
    body.main-page:has(.chat-active) #cameraBtn,
    body.chat-page #cameraBtn {
        display: none !important;
    }

    body.main-page:has(.chat-active) .chat-input,
    body.chat-page .chat-input {
        font-size: 16px;
        line-height: 1.35;
    }

    body.main-page:has(.chat-active) .chat-input-wrapper,
    body.chat-page .chat-input-wrapper {
        min-height: 20px;
        flex: 1;
        min-width: 0;
    }

    body.main-page .stories-container {
        display: none;
    }

    body.main-page .sidebar {
        top: 48px;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        height: auto;
    }

    body.main-page:has(.chat-active) .sidebar {
        top: 0;
        bottom: 0;
    }
    
    .chat-header-area {
        height: 48px;
        min-height: 48px;
        padding: 0 8px;
    }
    
    .chat-back-btn {
        display: flex;
    }

    .sidebar-header {
        padding: 10px 10px 8px;
    }

    .sidebar-title {
        margin-bottom: 8px;
        font-size: 15px;
    }

    .tabs {
        margin-bottom: 8px;
        gap: 4px;
    }

    .premium-panel {
        margin: 8px 10px;
        padding: 10px 12px;
    }

    body.main-page .sidebar .tabs {
        display: none;
    }

    .chat-item {
        min-height: 58px;
        padding: 8px 10px;
    }

    .chat-avatar {
        margin-right: 10px;
    }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    min-width: 0;
    flex: 1;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    z-index: 1;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: inherit;
}

.bottom-nav-item:focus {
    outline: none;
}

.bottom-nav-item i {
    font-size: 19px;
    transition: var(--transition);
}

.bottom-nav-item span {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bottom-nav-item.bottom-nav-pro.is-pro i {
    color: var(--premium);
}

.bottom-nav-item.bottom-nav-pro.active {
    color: var(--premium);
}

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

.bottom-nav-item.active i {
    transform: scale(1.1);
}

.bottom-nav-item:hover {
    color: var(--primary);
}

.bottom-nav-item:active {
    transform: scale(0.9);
    opacity: 0.8;
}

/* Индикатор уведомлений на иконке */
.bottom-nav-item .badge {
    position: absolute;
    top: 4px;
    right: 8px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

/* Компактная кнопка «Создать» на groups/channels — переопределяет глобальные button-стили */
a.create-btn,
button.create-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 6px 12px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: fit-content !important;
    flex: 0 0 auto !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    border-radius: var(--radius-sm) !important;
    background: var(--primary) !important;
    color: #fff !important;
    border: none !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    touch-action: manipulation !important;
}

a.create-btn:hover,
button.create-btn:hover {
    background: var(--primary-dark) !important;
    color: #fff !important;
}

a.create-btn i,
button.create-btn i {
    font-size: 11px !important;
}

@media (max-width: 480px) {
    a.create-btn,
    button.create-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
}

@media (max-width: 360px) {
    a.create-btn span,
    button.create-btn span {
        display: none !important;
    }
    a.create-btn,
    button.create-btn {
        padding: 6px 8px !important;
        min-width: 32px !important;
        max-width: 32px !important;
    }
}

/* ——— App shell: компактные страницы списков ——— */
body.app-page {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    height: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
    display: block !important;
    background: var(--bg-dark);
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
}

.app-page-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(10px, 2.5vw, 20px) clamp(10px, 2.5vw, 16px);
}

.app-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: clamp(12px, 3vw, 20px);
}

.app-page-title {
    font-size: clamp(18px, 4.5vw, 26px);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.app-page-title i {
    color: var(--primary);
    flex-shrink: 0;
}

.app-page-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: clamp(10px, 2.5vw, 16px);
}

.app-card {
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    padding: clamp(12px, 3vw, 16px);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.app-card:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.app-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.app-card-avatar {
    width: clamp(44px, 11vw, 52px);
    height: clamp(44px, 11vw, 52px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(18px, 4.5vw, 22px);
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.app-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-card-info {
    flex: 1;
    min-width: 0;
}

.app-card-name {
    font-size: clamp(15px, 3.8vw, 17px);
    font-weight: 600;
    margin-bottom: 2px;
    word-break: break-word;
}

.app-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.app-card-desc {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.app-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.app-card-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.app-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.app-card-actions .app-action-btn {
    flex: 1;
    min-height: 34px !important;
    padding: 6px 10px !important;
    font-size: 12px !important;
    border-radius: var(--radius-sm) !important;
}

.app-empty {
    text-align: center;
    padding: clamp(32px, 8vw, 48px) 16px;
    color: var(--text-secondary);
}

.app-empty i {
    font-size: clamp(36px, 9vw, 48px);
    margin-bottom: 12px;
    opacity: 0.45;
}

.app-empty h3 {
    font-size: clamp(16px, 4vw, 18px);
    margin-bottom: 6px;
    color: var(--text-primary);
}

.app-empty p {
    font-size: 13px;
    margin-bottom: 12px;
}

@media (max-width: 768px) {
    .app-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .app-card {
        padding: 12px;
    }

    .app-page-content {
        padding: 10px 10px 12px;
    }

    .app-page-header {
        margin-bottom: 8px;
        justify-content: flex-end;
    }

    .app-page-header .app-page-title {
        display: none;
    }
}

/* ——— Chat Info page ——— */
.chat-info-page .chat-info-hero {
    text-align: center;
    padding: 14px 12px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

.chat-info-page .chat-info-hero-avatar {
    width: clamp(72px, 18vw, 96px);
    height: clamp(72px, 18vw, 96px);
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(28px, 7vw, 36px);
    font-weight: 700;
    color: #fff;
    overflow: hidden;
}

.chat-info-page .chat-info-hero-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-info-page .chat-info-hero-name {
    font-size: clamp(18px, 4.5vw, 22px);
    font-weight: 700;
    margin-bottom: 4px;
}

.chat-info-page .chat-info-hero-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.chat-info-page .chat-info-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.chat-info-page .chat-info-actions .action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    min-height: 40px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.chat-info-page .action-btn.primary {
    background: var(--primary);
    color: #fff;
}

.chat-info-page .action-btn.secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}

.chat-info-page .action-btn.danger {
    background: rgba(255, 59, 48, 0.15);
    color: var(--danger);
}

.chat-info-page .info-section {
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
}

.chat-info-page .info-section-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-info-page .stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.chat-info-page .stat-chip {
    text-align: center;
    padding: 10px 6px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.chat-info-page .stat-chip-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.chat-info-page .stat-chip-label {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.chat-info-page .member-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}

.chat-info-page .member-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.chat-info-page .member-item-main:hover {
    background: var(--bg-hover);
}

.member-menu-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-sidebar);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.member-menu-btn:hover,
.member-menu-btn:active {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}

.member-menu-btn i {
    font-size: 14px;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.role-badge--owner {
    background: rgba(255, 149, 0, 0.2);
    color: var(--accent);
}

.role-badge--admin {
    background: rgba(0, 136, 204, 0.2);
    color: var(--primary);
}

.chat-info-admin-hint {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
    background: rgba(0, 136, 204, 0.12);
    border: 1px solid rgba(0, 136, 204, 0.25);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.45;
}

.chat-info-admin-hint i {
    color: var(--primary);
    margin-top: 2px;
}

.chat-info-admin-hint strong {
    color: var(--text-primary);
}

.chat-info-desc {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.chat-info-actions--stack {
    flex-direction: column;
}

.chat-info-actions--stack .action-btn {
    width: 100%;
}

.member-search-wrap {
    position: relative;
    margin-bottom: 8px;
}

.member-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 13px;
    pointer-events: none;
}

.member-search {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.stat-chip-value--text {
    font-size: 12px !important;
    color: var(--text-primary) !important;
}

/* Accordion sections (chat info + profile) */
.info-accordion {
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 10px;
    overflow: hidden;
}

.info-accordion-summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.info-accordion-summary::-webkit-details-marker {
    display: none;
}

.info-accordion-summary::after {
    content: '\f078';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 11px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.info-accordion[open] .info-accordion-summary::after {
    transform: rotate(180deg);
}

.info-accordion-summary span:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.info-accordion-summary i {
    color: var(--primary);
    width: 16px;
    text-align: center;
}

.info-accordion-meta {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 6px;
}

.info-accordion > :not(summary) {
    padding: 0 14px 14px;
}

.info-accordion .stats-row,
.info-accordion .member-list,
.info-accordion .chat-admin-form,
.info-accordion .chat-info-actions {
    margin-top: 0;
}

/* Profile view page */
.profile-view-page .profile-view-hero {
    text-align: center;
    padding: 16px 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
}

.profile-view-avatar-wrap {
    position: relative;
    width: fit-content;
    margin: 0 auto 12px;
}

.profile-view-avatar {
    width: clamp(88px, 22vw, 108px);
    height: clamp(88px, 22vw, 108px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(32px, 8vw, 40px);
    font-weight: 700;
    color: #fff;
    overflow: hidden;
}

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

.profile-view-online {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--online);
    border: 3px solid var(--bg-sidebar);
}

.profile-view-name {
    font-size: clamp(20px, 5vw, 24px);
    font-weight: 700;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.profile-view-username {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 6px;
}

.profile-view-status {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--offline);
    display: inline-block;
}

.status-dot.online {
    background: var(--online);
}

.profile-view-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.profile-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--bg-input);
    font-size: 11px;
    color: var(--text-secondary);
}

.profile-stat-chip.pro {
    background: rgba(255, 215, 0, 0.12);
    color: var(--premium);
}

.profile-view-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.profile-view-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 64px;
    padding: 8px 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-sidebar);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.profile-view-btn i {
    font-size: 18px;
}

.profile-view-btn.primary {
    background: var(--primary);
    border-color: transparent;
    color: #fff;
}

.profile-view-btn.secondary:hover {
    background: var(--bg-hover);
}

.profile-view-bio {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.profile-stories-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.profile-story-chip {
    flex-shrink: 0;
}

.profile-story-ring {
    padding: 2px;
    border-radius: 50%;
    background: var(--gradient-primary);
}

.profile-story-thumb {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    border: 2px solid var(--bg-sidebar);
}

.profile-story-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    padding: 4px 0;
}

.profile-info-row a {
    color: var(--primary);
    text-decoration: none;
}

.profile-more-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-more-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.profile-more-item.muted {
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .profile-view-actions {
        grid-template-columns: repeat(3, 1fr);
    }

    .profile-view-btn span {
        font-size: 10px;
    }
}

@media (max-width: 380px) {
    .profile-view-actions {
        grid-template-columns: 1fr 1fr;
    }

    .profile-view-actions .profile-view-btn:last-child {
        grid-column: span 2;
    }
}

.chat-info-page .member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-info-page .member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-info-page .member-info {
    flex: 1;
    min-width: 0;
}

.chat-info-page .member-name {
    font-size: 14px;
    font-weight: 600;
}

.chat-info-page .member-role {
    font-size: 11px;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .chat-info-page .chat-info-actions {
        flex-direction: column;
    }

    .chat-info-page .chat-info-actions .action-btn {
        width: 100%;
    }
}

.chat-readonly-notice {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
}

.chat-readonly-notice i {
    color: var(--accent);
}

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

.chat-admin-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-admin-field span {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-admin-field input,
.chat-admin-field textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
}

.member-actions {
    display: flex;
    gap: 4px;
}

.member-manage-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
}

.chat-admin-modal {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.chat-admin-modal.active {
    display: flex;
}

.chat-admin-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.chat-admin-modal-sheet {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--bg-sidebar);
    border-radius: 16px 16px 0 0;
    padding: 12px 12px max(12px, env(safe-area-inset-bottom));
    animation: slideUpModal 0.25s ease;
}

.chat-admin-modal-title {
    font-weight: 700;
    font-size: 16px;
    padding: 8px 12px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.chat-admin-modal-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    text-align: left;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.chat-admin-modal-item:hover {
    background: var(--bg-hover);
}

.chat-admin-modal-item.danger {
    color: var(--danger);
}

.chat-admin-modal-item.cancel {
    justify-content: center;
    color: var(--text-secondary);
    margin-top: 4px;
}

@keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
