:root {
    /* Liquid Glass Theme Colors */
    --bg-color: #050505; /* Deep black background */
    --bg-secondary: rgba(255, 255, 255, 0.03); /* Glass container */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.4);
    --accent-color: rgba(255, 255, 255, 0.8);
    --accent-hover: #ffffff;
    --border-color: rgba(255, 255, 255, 0.08);
    
    --msg-in-bg: rgba(255, 255, 255, 0.05);
    --msg-out-bg: rgba(255, 255, 255, 0.15);
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --sidebar-width: 380px;
    
    --transition-speed: 0.3s;
    --transition: all var(--transition-speed) cubic-bezier(0.25, 0.8, 0.25, 1);
    --glass-blur: blur(20px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    background: var(--bg-color);
    background-image: radial-gradient(circle at 15% 50%, rgba(255, 255, 255, 0.04), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(255, 255, 255, 0.04), transparent 25%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Приложение */
.tg-app {
    width: 100vw;
    height: 100vh;
    display: flex;
    background: transparent;
}

.hidden {
    display: none !important;
}

/* Экран входа */
.tg-auth-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
}

.tg-auth-box {
    width: 100%;
    max-width: 380px;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
    
    /* Liquid Glass */
    background: var(--bg-secondary);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.tg-logo {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.05);
}

.tg-auth-box h2 {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 8px;
}

.tg-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 30px;
}

.tg-auth-tabs {
    display: flex;
    width: 100%;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 4px;
}

.tg-auth-tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.tg-auth-tab.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tg-input-group {
    width: 100%;
    margin-bottom: 16px;
}

.tg-input-group input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
}

.tg-input-group input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.tg-btn-primary {
    width: 100%;
    padding: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.tg-btn-primary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.tg-btn-link {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 20px;
}

.tg-btn-link:hover {
    text-decoration: underline;
}

.tg-status {
    margin-top: 15px;
    font-size: 14px;
    color: #f87171;
    text-align: center;
    min-height: 20px;
}

/* Главный экран (Main) */
.tg-main {
    width: 100%;
    height: 100%;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Шторка (Drawer) */
.tg-drawer {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    background: var(--bg-secondary);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.tg-drawer.open {
    transform: translateX(0);
}

.tg-drawer-header {
    padding: 24px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.drawer-user-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drawer-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.drawer-text h3 {
    margin: 0;
    font-size: 16px;
    color: #fff;
    font-weight: 500;
}

.drawer-text span {
    font-size: 14px;
    color: var(--text-secondary);
}

.tg-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.drawer-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background calc(0.67 * var(--transition-speed));
    font-size: 15px;
    font-weight: 500;
}

.drawer-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tg-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed) ease;
}

.tg-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Список чатов */
.tg-chat-list-view {
    width: 350px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background: var(--bg-color);
    flex-shrink: 0;
}

.tg-list-header {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.tg-header-title {
    flex: 1;
    margin: 0;
    font-size: 18px;
    color: #fff;
    font-weight: 500;
    padding-left: 8px;
}

.tg-search-bar-container {
    padding: 8px 16px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    transition: all var(--transition-speed) ease;
}

.tg-search-bar-container.hidden {
    display: none;
}

.tg-search-bar-container input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 8px 16px;
    color: var(--text-primary);
    font-size: 14px;
}

.tg-search-bar-container input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.tg-dialogs-list {
    flex: 1;
    overflow-y: auto;
}

.tg-dialogs-list::-webkit-scrollbar {
    width: 4px;
}
.tg-dialogs-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Стилизация контактов/чатов */
.tg-contact-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background calc(0.5 * var(--transition-speed));
    border-bottom: 1px solid rgba(255,255,255,0.02);
}

.tg-contact-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.tg-contact-item.active {
    background: rgba(var(--accent-color-rgb, 59, 130, 246), 0.15);
    border-left: 3px solid var(--accent-color);
}

.tg-contact-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: 500;
    color: #fff;
    flex-shrink: 0;
    background: var(--accent-color);
}

.tg-contact-info {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tg-contact-name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tg-contact-msg {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Область чата (правая часть) */
.tg-chat-area-view {
    flex: 1;
    height: 100%;
    background: var(--bg-color);
    position: relative;
    display: flex;
    flex-direction: column;
}

.tg-empty-state {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tg-empty-badge {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-primary);
}

.tg-chat-window {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.tg-chat-header {
    height: 56px;
    background: var(--bg-secondary);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.back-btn {
    display: none; /* Показана только на мобильных */
}

.tg-peer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-weight: 500;
    background: var(--accent-color);
}

.tg-peer-info h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.tg-peer-status {
    font-size: 13px;
    color: var(--accent-color);
}

.tg-messages-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Узнаваемый паттерн телеги можно добавить через background-image */
}

.tg-messages-scroll::-webkit-scrollbar {
    width: 6px;
}
.tg-messages-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.tg-msg-wrapper {
    display: flex;
    width: 100%;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.tg-msg-wrapper.msg-anim-appear {
    animation: msgAppear 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.tg-msg-wrapper.out.msg-anim-appear {
    animation: msgAppearOut 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes msgAppear {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
@keyframes msgAppearOut {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    font-size: 11px;
    vertical-align: middle;
}
.msg-status-icon i.fa-clock {
    animation: clockSpin 1.5s linear infinite;
}
@keyframes clockSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tg-msg-wrapper.in {
    justify-content: flex-start;
}

.tg-msg-wrapper.out {
    justify-content: flex-end;
}

.tg-msg-bubble {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.4;
    word-break: break-word;
    position: relative;
}

.tg-msg-wrapper.in .tg-msg-bubble {
    background: var(--msg-in-bg);
    border-bottom-left-radius: 4px;
}

.tg-msg-wrapper.out .tg-msg-bubble {
    background: var(--msg-out-bg);
    border-bottom-right-radius: 4px;
}

.tg-msg-time {
    font-size: 11px;
    color: var(--text-muted);
    float: right;
    margin-top: 6px;
    margin-left: 10px;
}

.tg-msg-wrapper.out .tg-msg-time {
    color: rgba(255, 255, 255, 0.6);
}

/* Поле ввода */
.tg-chat-input {
    min-height: 56px;
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 10px 10px calc(15px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
}

.tg-chat-input input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 10px 0;
}

.tg-chat-input input:focus {
    outline: none;
}

.tg-btn-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.tg-btn-icon:hover {
    color: var(--accent-color);
}

.tg-send-btn {
    color: rgba(255, 255, 255, 0.8);
}
.tg-send-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* Адаптив (мобилки) */
@media (max-width: 768px) {
    .tg-chat-list-view {
        width: 100vw;
    }
    
    .tg-chat-area-view {
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100vw;
        height: 100vh;
        z-index: 50;
        transform: translateX(100%);
        transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .tg-chat-area-view.mobile-open {
        transform: translateX(0);
    }
    
    .back-btn {
        display: flex;
        margin-left: -8px;
    }
}

/* Картинки в сообщениях */
.tg-msg-image {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 4px;
    display: block;
}

/* Контекстное меню сообщений */
.tg-context-menu {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 100;
    min-width: 160px;
    overflow: hidden;
    animation: fadeIn calc(0.5 * var(--transition-speed)) ease-out;
}

.tg-context-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background calc(0.5 * var(--transition-speed));
}

.tg-context-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.tg-context-item.danger {
    color: #ef4444;
}

.tg-context-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.tg-msg-edited {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    margin-left: 4px;
}

/* Call UI Overlay */
.tg-call-screen {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: #0d0d0d;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 1;
    visibility: visible;
    transition: opacity var(--transition-speed) cubic-bezier(0.1, 1, 0.1, 1), visibility var(--transition-speed), transform var(--transition-speed) cubic-bezier(0.1, 1, 0.1, 1);
    transform: scale(1);
}

.tg-call-screen.hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.1);
    pointer-events: none;
}

.call-avatar-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
    transition: opacity calc(1.67 * var(--transition-speed)) ease, transform calc(1.67 * var(--transition-speed)) ease;
}

.call-avatar-container.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.call-avatar-pulsing {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #8774e1);
    color: #fff;
    font-size: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    box-shadow: 0 0 0 0 rgba(135, 116, 225, 0.6);
    animation: call-pulse 2s infinite;
}

@keyframes call-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(135, 116, 225, 0.6);
    }
    70% {
        box-shadow: 0 0 0 25px rgba(135, 116, 225, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(135, 116, 225, 0);
    }
}

.call-video-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0;
    transition: opacity calc(1.67 * var(--transition-speed)) ease;
    background: #000;
}

.call-video-container.active {
    opacity: 1;
}

#remote-video {
    width: 100%; height: 100%;
    object-fit: cover;
    background: #000;
}

#local-video {
    position: absolute;
    bottom: 120px; right: 20px;
    width: 90px; height: 130px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    background: #111;
    z-index: 10;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    transform: scale(0);
    opacity: 0;
    transition: transform var(--transition-speed) cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity var(--transition-speed) ease;
}

#local-video.active {
    transform: scale(1);
    opacity: 1;
}

.call-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 60px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 35%, transparent 65%, rgba(0,0,0,0.8) 100%);
    pointer-events: none;
    z-index: 20;
}

#call-peer-name {
    color: #fff;
    font-size: 28px;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#call-status {
    color: rgba(255,255,255,0.7);
    font-size: 16px;
    margin-top: 8px;
}

.call-controls {
    position: absolute;
    bottom: 40px;
    display: flex;
    gap: 24px;
    pointer-events: auto;
}

.call-controls.hidden {
    display: none !important;
}

.call-btn {
    width: 60px; height: 60px;
    border-radius: 50%;
    border: none;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
    color: #fff;
    transition: transform calc(0.67 * var(--transition-speed)), background var(--transition-speed), box-shadow var(--transition-speed);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.call-btn:hover {
    transform: translateY(-2px);
}

.call-btn:active {
    transform: translateY(1px) scale(0.95);
}

.call-btn.accept {
    background: #10b981;
    animation: accept-pulse 1.8s infinite;
}

@keyframes accept-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7), 0 4px 16px rgba(0,0,0,0.3);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(16, 185, 129, 0), 0 4px 16px rgba(0,0,0,0.3);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0), 0 4px 16px rgba(0,0,0,0.3);
    }
}

.call-btn.decline {
    background: #ef4444;
}

.call-btn.secondary {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.call-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.call-btn.secondary.off {
    background: #fff;
    color: #111;
}

.tg-chat-actions {
    display: flex;
    gap: 8px;
    margin-right: 16px;
}
/* Settings Modal */
.tg-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    opacity: 1;
    visibility: visible;
    transition: opacity var(--transition-speed) ease, visibility var(--transition-speed) ease;
}
.tg-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.tg-modal-content {
    background: var(--bg-primary);
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
    transform: scale(1);
    transition: transform var(--transition-speed) cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tg-modal.hidden .tg-modal-content {
    transform: scale(0.92);
}
.tg-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.tg-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}
.tg-modal-body {
    padding: 20px;
}
.avatar-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}
.settings-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #8774e1);
    color: #fff;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    background-size: cover;
    background-position: center;
}
.username-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding-left: 10px;
}
.username-input-wrapper .at-symbol {
    color: var(--text-secondary);
    font-weight: 500;
}
.username-input-wrapper input {
    background: transparent;
    border: none;
    box-shadow: none;
    padding-left: 5px;
}

/* Recording Panel */
.tg-recording-panel {
    min-height: 56px;
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--text-primary);
}

.recording-dot {
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    animation: blink 1s infinite alternate;
}

@keyframes blink {
    from { opacity: 1; }
    to { opacity: 0.3; }
}

.recording-preview-container {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    border: 2px solid var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

#recording-video-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recording-actions {
    display: flex;
    gap: 12px;
}

.danger-icon {
    color: #ef4444 !important;
}
.danger-icon:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

.success-icon {
    color: #10b981 !important;
}
.success-icon:hover {
    background: rgba(16, 185, 129, 0.1) !important;
}

/* Voice Message Player Bubble styles */
.tg-voice-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 4px;
    min-width: 180px;
}

.voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-color);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: transform calc(0.67 * var(--transition-speed));
}

.voice-play-btn:hover {
    transform: scale(1.05);
}

.voice-progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.voice-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
    outline: none;
}

.voice-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

.voice-duration {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

/* Telegram Video Message (Circle) */
.tg-msg-video-msg {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    border: 2px solid var(--accent-color);
    background: #000;
    margin-bottom: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tg-msg-video-msg video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* File Message Bubble Hover */
.tg-file-message:hover .file-icon-btn {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* Minimized Call Bar */
.tg-mini-call-bar {
    height: 48px;
    background: linear-gradient(90deg, #2b5278, #1a3652);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    z-index: 1000;
    animation: slideDown var(--transition-speed) ease-out;
    user-select: none;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.mini-call-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
    height: 100%;
}

.mini-pulse-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: mini-pulse 1.5s infinite alternate;
}

@keyframes mini-pulse {
    from { transform: scale(0.8); opacity: 0.5; }
    to { transform: scale(1.2); opacity: 1; }
}

.mini-call-actions {
    display: flex;
    gap: 8px;
}

.mini-call-action-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: background calc(0.67 * var(--transition-speed));
}

.mini-call-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mini-call-action-btn.decline {
    background: #ef4444;
}
.mini-call-action-btn.decline:hover {
    background: #dc2626;
}

/* Style adjustments for reply preview */
.tg-reply-preview-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 0;
    opacity: 0;
    overflow: hidden;
    background: rgba(255,255,255,0.02);
    border-top: 0px solid var(--border-color);
    border-left: 3px solid var(--accent-color);
    transition: height 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), 
                opacity 0.2s ease, 
                padding 0.24s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-top-width 0.24s ease;
}

.tg-reply-preview-container.active {
    height: 48px;
    opacity: 1;
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
}

.reply-preview-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow: hidden;
}

.reply-preview-author {
    font-weight: 500;
    font-size: 13px;
    color: var(--accent-color);
}

.reply-preview-text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80vw;
}

.reply-quote-bubble {
    background: rgba(255,255,255,0.05);
    border-left: 2.5px solid var(--accent-color);
    padding: 4px 8px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background calc(0.67 * var(--transition-speed));
}
.reply-quote-bubble:hover {
    background: rgba(255,255,255,0.08);
}

.reply-quote-author {
    font-weight: 500;
    color: var(--accent-color);
    font-size: 12px;
    margin-bottom: 2px;
}
.reply-quote-text {
    color: var(--text-secondary);
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes flashHighlight {
    0% { background-color: rgba(135, 116, 225, 0.4); }
    100% { background-color: transparent; }
}
.flash-highlight {
    animation: flashHighlight 1s ease-out;
}

/* --- THEME VARIATIONS --- */

/* White (Light) Theme */
body.theme-white {
    --bg-color: #f5f6fa;
    --bg-secondary: rgba(0, 0, 0, 0.04);
    --text-primary: #2f3640;
    --text-secondary: #718093;
    --text-muted: #a4b0be;
    --accent-color: #2481cc;
    --accent-hover: #1a5c91;
    --border-color: rgba(0, 0, 0, 0.08);
    --msg-in-bg: rgba(0, 0, 0, 0.05);
    --msg-out-bg: rgba(36, 129, 204, 0.15);
}
body.theme-white {
    background-image: radial-gradient(circle at 15% 50%, rgba(0, 0, 0, 0.02), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(0, 0, 0, 0.02), transparent 25%);
    background-color: #f5f6fa;
    color: #2f3640;
}
body.theme-white .tg-sidebar,
body.theme-white .tg-chat-area-view,
body.theme-white .tg-drawer-content,
body.theme-white .tg-modal-content,
body.theme-white .tg-context-menu {
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.05);
}
body.theme-white .tg-contact-item.active {
    background: rgba(36, 129, 204, 0.1);
}
body.theme-white .tg-msg-bubble {
    color: #2f3640;
}
body.theme-white .tg-input {
    background: #f1f2f6;
    color: #2f3640;
}

/* Black (Deep Dark) Theme */
body.theme-black {
    --bg-color: #000000;
    --bg-secondary: rgba(255, 255, 255, 0.04);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #606060;
    --accent-color: #ffffff;
    --accent-hover: #cccccc;
    --border-color: rgba(255, 255, 255, 0.1);
    --msg-in-bg: rgba(255, 255, 255, 0.08);
    --msg-out-bg: rgba(255, 255, 255, 0.2);
}
body.theme-black {
    background-image: none;
    background-color: #000000;
}
body.theme-black .tg-sidebar,
body.theme-black .tg-chat-area-view,
body.theme-black .tg-drawer-content,
body.theme-black .tg-modal-content,
body.theme-black .tg-context-menu {
    background: #090909;
    border: 1px solid #1a1a1a;
}

/* Blue (Telegram Classic) Theme */
body.theme-blue {
    --bg-color: #0e1621;
    --bg-secondary: #17212b;
    --text-primary: #f5f6fa;
    --text-secondary: #7f91a4;
    --text-muted: #54687a;
    --accent-color: #2481cc;
    --accent-hover: #2f9beb;
    --border-color: #101924;
    --msg-in-bg: #182533;
    --msg-out-bg: #2b5278;
}
body.theme-blue {
    background-image: none;
    background-color: #0e1621;
}
body.theme-blue .tg-sidebar,
body.theme-blue .tg-chat-area-view,
body.theme-blue .tg-drawer-content,
body.theme-blue .tg-modal-content,
body.theme-blue .tg-context-menu {
    background: #17212b;
    border: 1px solid #101924;
}

/* Pink (Cute Pink) Theme */
body.theme-pink {
    --bg-color: #fff0f5;
    --bg-secondary: #ffe4e1;
    --text-primary: #4a1525;
    --text-secondary: #8b4f58;
    --text-muted: #b8860b;
    --accent-color: #ff69b4;
    --accent-hover: #ff1493;
    --border-color: #ffc0cb;
    --msg-in-bg: #ffffff;
    --msg-out-bg: #ffd1dc;
}
body.theme-pink {
    background-color: #fff0f5;
    background-image: radial-gradient(circle at 15% 50%, rgba(255, 105, 180, 0.05), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(255, 105, 180, 0.05), transparent 25%);
}
body.theme-pink .tg-sidebar,
body.theme-pink .tg-chat-area-view,
body.theme-pink .tg-drawer-content,
body.theme-pink .tg-modal-content,
body.theme-pink .tg-context-menu {
    background: #fff9fa;
    border: 1px solid #ffe4e1;
    box-shadow: 0 4px 20px rgba(255, 105, 180, 0.05);
}
body.theme-pink .tg-contact-item.active {
    background: rgba(255, 105, 180, 0.1);
}
body.theme-pink .tg-msg-bubble {
    color: #4a1525;
}
body.theme-pink .tg-input {
    background: #fff0f5;
    color: #4a1525;
}

/* Pickme Theme (pastel contrasting theme) */
body.theme-pickme {
    --bg-color: #f7f1e3;
    --bg-secondary: #d1ccc0;
    --text-primary: #2c2c54;
    --text-secondary: #474787;
    --text-muted: #aaa69d;
    --accent-color: #ff5252;
    --accent-hover: #ff793f;
    --border-color: rgba(0,0,0,0.1);
    --msg-in-bg: #ffffff;
    --msg-out-bg: #ffb142;
}
body.theme-pickme {
    background-color: #f7f1e3;
}
body.theme-pickme .tg-sidebar,
body.theme-pickme .tg-chat-area-view,
body.theme-pickme .tg-drawer-content,
body.theme-pickme .tg-modal-content,
body.theme-pickme .tg-context-menu {
    background: #f1ebd9;
    border: 1px solid #d1ccc0;
}
body.theme-pickme .tg-contact-item.active {
    background: rgba(255, 82, 82, 0.1);
}
body.theme-pickme .tg-input {
    background: #e5deb3;
    color: #2c2c54;
}

/* Anime Theme (violet-pink blossom glowing theme) */
body.theme-anime {
    --bg-color: #1a1a2e;
    --bg-secondary: #16213e;
    --text-primary: #e2e2e2;
    --text-secondary: #a8a8b2;
    --text-muted: #6a6a77;
    --accent-color: #e94560;
    --accent-hover: #ff6b8b;
    --border-color: rgba(233, 69, 96, 0.2);
    --msg-in-bg: #0f3460;
    --msg-out-bg: #e94560;
}
body.theme-anime {
    background-color: #1a1a2e;
    background-image: radial-gradient(circle at 10% 20%, rgba(233, 69, 96, 0.1), transparent 30%),
                      radial-gradient(circle at 90% 80%, rgba(233, 69, 96, 0.1), transparent 30%);
}
body.theme-anime .tg-sidebar,
body.theme-anime .tg-chat-area-view,
body.theme-anime .tg-drawer-content,
body.theme-anime .tg-modal-content,
body.theme-anime .tg-context-menu {
    background: #16213e;
    border: 1px solid rgba(233, 69, 96, 0.2);
}
body.theme-anime .tg-contact-item.active {
    background: rgba(233, 69, 96, 0.15);
}

/* --- ATTACHMENT DRAWER STYLING --- */
.tg-attachment-drawer {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 1;
    visibility: visible;
    transition: opacity var(--transition-speed) ease, visibility var(--transition-speed) ease;
}
.tg-attachment-drawer.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.attachment-drawer-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}
.attachment-drawer-content {
    background: var(--bg-primary);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 2;
    transform: translateY(0);
    transition: transform var(--transition-speed) cubic-bezier(0.1, 1, 0.1, 1);
    box-shadow: 0 -5px 25px rgba(0,0,0,0.15);
}
.tg-attachment-drawer.hidden .attachment-drawer-content {
    transform: translateY(100%);
}
.attachment-drag-handle {
    width: 40px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
    margin: 0 auto 15px;
}
.gallery-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 0 15px;
}
.gallery-scroll::-webkit-scrollbar {
    display: none;
}
.gallery-item-mock {
    flex: 0 0 100px;
    height: 100px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color calc(0.67 * var(--transition-speed)), transform calc(0.67 * var(--transition-speed));
}
.gallery-item-mock:hover {
    border-color: var(--accent-color);
    transform: scale(1.02);
}
.gallery-item-mock svg, .gallery-item-mock img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    text-align: center;
    margin-top: 10px;
}
.attachment-grid .grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.attachment-grid .grid-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    transition: transform calc(0.67 * var(--transition-speed));
}
.attachment-grid .grid-item:hover .grid-icon {
    transform: scale(1.08);
}
.grid-icon.gallery { background: #29b6f6; }
.grid-icon.file { background: #ab47bc; }
.grid-icon.location { background: #26a69a; }
.grid-icon.contact { background: #ffa726; }
.attachment-grid span {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Æther Custom Styles (0.2.9.6) --- */
.tg-peer-info {
    flex: 1;
    min-width: 0;
}

.drawer-avatar,
.settings-avatar,
.tg-contact-avatar,
.tg-peer-avatar,
.call-avatar-pulsing,
#call-avatar,
#profile-avatar-display {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Online presence dot */
.tg-contact-item-wrapper {
    position: relative;
}
.online-dot {
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid var(--bg-color);
    border-radius: 50%;
    position: absolute;
    bottom: 10px;
    left: 52px;
    z-index: 2;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
    animation: onlinePulse 2s ease-in-out infinite;
}
@keyframes onlinePulse {
    0%, 100% { box-shadow: 0 0 4px rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 10px rgba(34, 197, 94, 0.8); }
}

.tg-peer-status.online {
    color: #22c55e;
}
.tg-peer-status.offline {
    color: var(--text-secondary);
}

/* Chat loading indicator */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    gap: 10px;
}
.chat-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* In-app toast notifications */
.in-app-toast {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    min-width: 280px;
    max-width: 90vw;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px) saturate(1.6);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    transition: transform 0.35s cubic-bezier(0.33, 1, 0.68, 1), opacity 0.35s ease;
    opacity: 0;
    pointer-events: none;
}
.in-app-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.in-app-toast.hiding {
    transform: translateX(-50%) translateY(-120%);
    opacity: 0;
}
.in-app-toast-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}
.in-app-toast-content {
    flex: 1;
    min-width: 0;
}
.in-app-toast-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.in-app-toast-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Unread Badge */
.tg-unread-badge {
    background: var(--accent-color);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
    margin-left: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Reactions Badge */
.tg-msg-reactions {
    display: flex;
    align-items: center;
    gap: 4px;
    position: absolute;
    bottom: -11px;
    right: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: 20px;
    padding: 2px 7px;
    font-size: 11.5px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    z-index: 100;
    user-select: none;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tg-msg-reactions:hover {
    transform: scale(1.08);
}
.tg-msg-reactions:active {
    transform: scale(0.95);
}
.tg-msg-wrapper.in .tg-msg-reactions {
    right: auto;
    left: 12px;
}
.tg-reaction-item {
    display: flex;
    align-items: center;
    gap: 2.5px;
}
.tg-reaction-count {
    font-weight: 600;
    opacity: 0.85;
}

