        :root {
            --bg-main: var(--bg-card);
            --bg-sidebar: var(--bg-body);
            --bg-input: var(--bg-body);
            --msg-user-bg: var(--bg-body);
            --msg-user-text: var(--text-primary);
            --msg-bot-bg: transparent;
            --promo-bg: var(--bg-card);
            --promo-hover: rgba(0,0,0,0.03);
        }
        [data-theme="dark"] {
            --bg-main: var(--bg-card);
            --bg-sidebar: var(--bg-body);
            --bg-input: var(--bg-body);
            --msg-user-bg: #282a2c;
            --msg-user-text: var(--text-primary);
            --msg-bot-bg: transparent;
            --promo-bg: #282a2c;
            --promo-hover: #3c4043;
        }
        ::-webkit-scrollbar { width: 0px !important; display: none !important; }
        * { -ms-overflow-style: none; scrollbar-width: none; box-sizing: border-box; }
        body {
            background-color: var(--bg-main);
            color: var(--text-primary);
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            margin: 0;
            height: 100dvh;
            display: flex;
            overflow: hidden;
            transition: background-color 0.3s, color 0.3s;
        }
        .sidebar {
            width: 280px; flex-shrink: 0;
            background-color: var(--bg-sidebar);
            display: flex; flex-direction: column;
            transition: margin-left 0.3s ease;
            z-index: 1050;
            border-right: 1px solid var(--border-color);
        }
        .sidebar.collapsed { margin-left: -280px; border-right: none; }
        .sidebar-header { padding: 20px; display: flex; align-items: center; gap: 15px; }
        .icon-btn {
            background: transparent; border: none; color: var(--text-primary);
            font-size: 24px; cursor: pointer; padding: 5px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center; width: 40px; height: 40px;
        }
        .icon-btn:hover { background-color: rgba(128,128,128,0.1); }
        .sidebar-content { flex: 1; overflow-y: auto; padding: 10px 20px; display: flex; flex-direction: column; gap: 15px; }
        .btn-action-custom {
            background-color: var(--btn-bg) !important; color: var(--btn-text) !important;
            border: none !important; border-radius: 24px !important;
            padding: 10px 20px !important; font-weight: 600 !important;
            transition: opacity 0.2s !important;
            display: inline-block; text-align: center; text-decoration: none; cursor: pointer;
        }
        .btn-action-custom:hover { opacity: 0.8 !important; }
        .mini-promo {
            background: var(--promo-bg); border: 1px solid var(--border-color);
            border-radius: 12px; padding: 12px; display: block; text-decoration: none; color: var(--text-primary);
        }
        .mini-promo h6 { margin: 0 0 4px 0; font-size: 14px; font-weight: 600; }
        .mini-promo p { margin: 0; font-size: 12px; color: var(--text-secondary); }
        .main-area { flex: 1; display: flex; flex-direction: column; position: relative; width: 100%; }
        .top-bar { 
            padding: 10px 20px; display: flex; align-items: center; justify-content: space-between;
            min-height: 60px; border-bottom: 1px solid var(--border-color); background: var(--bg-card);
        }
        .menu-toggle-main { display: none; }
        .sidebar.collapsed ~ .main-area .menu-toggle-main { display: block; }
        .chat-wrapper {
            flex: 1; max-width: 850px; width: 100%; margin: 0 auto;
            display: flex; flex-direction: column; padding: 0 20px; overflow: hidden; margin-top: 10px;
        }
        #messages-scroll-area {
            flex: 1; overflow-y: auto; display: flex; flex-direction: column; padding-bottom: 20px;
        }
        #chat-container { flex: 1; display: flex; flex-direction: column; }
        .message { margin-bottom: 20px; line-height: 1.5; font-size: 16px; word-wrap: break-word; }
        .user-message {
            background-color: var(--msg-user-bg); color: var(--msg-user-text);
            align-self: flex-end; padding: 12px 18px; border-radius: 24px; max-width: 80%;
        }
        .bot-message { background-color: var(--msg-bot-bg); color: var(--text-primary); align-self: flex-start; padding: 0 5px; width: 100%; }
        #course-ui { background: var(--bg-input); border-radius: 16px; padding: 20px; margin-bottom: 20px; display: none; border: 1px solid var(--border-color); }
        #input-group { padding: 10px 0 15px; background: var(--bg-main); width: 100%; }
        .input-container {
            background-color: var(--bg-input); border-radius: 24px; border: 1px solid var(--border-color);
            padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; width: 100%;
        }
        #user-input {
            background: transparent; border: none; color: var(--text-primary);
            font-size: 16px; outline: none; width: 100%;
            resize: none; min-height: 24px; max-height: 200px; overflow-y: auto;
            padding: 0; margin: 0; line-height: 1.5;
        }
        input::placeholder, textarea::placeholder { color: var(--text-secondary) !important; opacity: 1 !important; }
        .input-controls { display: flex; justify-content: space-between; align-items: center; }
        #send-btn {
            background-color: var(--text-primary); color: var(--bg-main);
            border: none; border-radius: 50%; width: 40px; height: 40px; 
            display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; margin: 0;
            transition: opacity 0.2s;
        }
        #send-btn:hover { opacity: 0.8; }
        .typing-container { padding: 0 10px; margin-bottom: 10px; display: none; }
        .dot { width: 6px; height: 6px; background: var(--text-secondary); border-radius: 50%; display: inline-block; animation: bounce 1.4s infinite; margin-right: 4px; }
        .dot:nth-child(2) { animation-delay: 0.2s; }
        .dot:nth-child(3) { animation-delay: 0.4s; }
        @keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
        .sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1040; opacity: 0; }
        @media (max-width: 768px) {
            .sidebar { position: absolute; height: 100%; top: 0; left: 0; }
            .sidebar.collapsed { margin-left: -280px; }
            .sidebar:not(.collapsed) ~ .sidebar-overlay { display: block; opacity: 1; }
            .menu-toggle-main { display: block !important; }
            .chat-wrapper { padding: 0 10px; }
        }
        .btn-loading-dots { display: flex; align-items: center; justify-content: center; gap: 4px; height: 24px; }
        .btn-dot {
            width: 6px; height: 6px; background: var(--btn-text) !important; border-radius: 50%;
            display: inline-block; animation: bounce-btn 1.4s infinite;
        }
        .btn-dot:nth-child(1) { animation-delay: 0s; }
        .btn-dot:nth-child(2) { animation-delay: 0.2s; }
        .btn-dot:nth-child(3) { animation-delay: 0.4s; }
        @keyframes bounce-btn { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
        .modal-content { background-color: var(--bg-main) !important; color: var(--text-primary) !important; border-radius: 24px; border: 1px solid var(--border-color); }
        .modal-header { border-bottom: none; }
        .form-control { background-color: var(--bg-input) !important; border: 1px solid var(--border-color) !important; color: var(--text-primary) !important; border-radius: 12px; }
        .profile-info-box { background: var(--bg-input); border-radius: 12px; padding: 15px; margin-bottom: 15px; font-size: 0.9rem; border: 1px solid var(--border-color); }
        .sub-badge { display: inline-block; padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; margin-top: 10px; }
        .sub-active { background: #d1e7dd; color: #0f5132; }
        .sub-inactive { background: #f8d7da; color: #842029; }
        .chat-footer { padding: 5px 15px 15px; text-align: center; font-size: 11px; color: var(--text-secondary); border-top: none !important; background: var(--bg-main); }
        .chat-footer a { color: var(--text-primary); font-weight: 600; text-decoration: none; }
        .dropdown-item:active, .dropdown-item:focus, .dropdown-item:hover {
            background-color: var(--promo-hover) !important;
            color: var(--text-primary) !important;
        }

/* === Telegram Mini App fullscreen fix (iOS) === */
html, body {
    height: 100dvh !important;  /* dynamic viewport height */
    min-height: -webkit-fill-available;
    overscroll-behavior: none;
}

.chat-wrapper,
.main-area,
#messages-scroll-area {
    height: 100%;
}

/* Убираем отступ снизу */
body {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-top: env(safe-area-inset-top, 0px);
}

/* Растягиваем на всю ширину */
.sidebar,
.main-area {
    height: 100dvh;
}