:root {
    --bg-color: #0e1621;
    --sidebar-bg: #17212b;
    --chat-bg: #17212b;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    --accent-color: #38bdf8;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --message-own: #2a779e;
    --message-other: #212d3b;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

body.app-landing-body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow: auto;
    align-items: center;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 34%),
        linear-gradient(180deg, #0e1621 0%, #111b28 100%);
}

body.landing-body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow: auto;
    align-items: center;
    background:
        radial-gradient(circle at 12% 12%, rgba(56, 189, 248, 0.16), transparent 30%),
        linear-gradient(180deg, #0e1621 0%, #111b28 100%);
}

.landing-page {
    width: min(920px, 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    padding: clamp(24px, 5vw, 56px);
}

.landing-copy {
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: flex-start;
    position: relative;
}

.landing-copy::after {
    content: '';
    width: min(520px, 78vw);
    height: 1px;
    margin-top: 12px;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.8), rgba(56, 189, 248, 0));
}

.landing-wordmark {
    color: var(--accent-color);
    font-size: 1.1rem;
    font-weight: 700;
}

.landing-copy h1 {
    max-width: 620px;
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1.06;
}

.landing-copy p {
    max-width: 520px;
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.6;
}

.landing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.landing-button {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 12px;
    padding: 0 18px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.landing-button.primary {
    border-color: transparent;
    background: var(--accent-color);
    color: var(--text-primary);
}

.landing-button.secondary {
    background: rgba(255, 255, 255, 0.04);
}

.landing-button.download {
    background: rgba(56, 189, 248, 0.12);
}

.landing-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

@media (max-width: 760px) {
    .landing-page {
        min-height: 100dvh;
        align-items: flex-start;
        min-height: auto;
        padding: 28px 20px 24px;
    }

    .landing-copy {
        gap: 16px;
        width: 100%;
    }

    .landing-wordmark {
        font-size: 1rem;
    }

    .landing-copy h1 {
        font-size: 2rem;
        line-height: 1.08;
    }

    .landing-copy p {
        font-size: 0.98rem;
        line-height: 1.55;
    }

    .landing-actions {
        width: 100%;
        flex-direction: column;
        margin-top: 10px;
    }

    .landing-button {
        width: 100%;
    }

    .landing-copy::after {
        width: 100%;
        margin-top: 6px;
    }
}

.app-landing {
    width: min(1080px, 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(280px, 420px);
    align-items: center;
    gap: clamp(32px, 7vw, 96px);
    padding: clamp(24px, 5vw, 56px);
}

.app-hero {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
}

.app-wordmark {
    color: var(--accent-color);
    font-size: 1rem;
    font-weight: 700;
}

.app-hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.05;
}

.app-hero p {
    max-width: 520px;
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.6;
}

.app-download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 22px;
    border-radius: 12px;
    background: var(--accent-color);
    color: #062233;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 18px 40px rgba(56, 189, 248, 0.22);
}

.app-preview {
    display: flex;
    justify-content: center;
}

.phone-shell {
    width: min(320px, 80vw);
    aspect-ratio: 0.54;
    padding: 18px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(23, 33, 43, 0.92);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

.phone-header {
    height: 52px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--glass-border);
}

.phone-header span {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-color);
}

.phone-chat {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 22px;
}

.phone-chat .bubble {
    max-width: 78%;
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.35;
}

.phone-chat .bubble.other {
    background: var(--message-other);
}

.phone-chat .bubble.own {
    align-self: flex-end;
    background: var(--message-own);
}

.voice-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 82%;
    padding: 12px;
    border-radius: 16px;
    background: var(--message-other);
}

.play-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-color);
}

.voice-bars {
    flex: 1;
    height: 20px;
    background: repeating-linear-gradient(
        90deg,
        rgba(56, 189, 248, 0.92) 0 3px,
        transparent 3px 7px
    );
    opacity: 0.85;
}

.voice-chip small {
    color: var(--text-secondary);
}

@media (max-width: 760px) {
    .app-landing {
        grid-template-columns: 1fr;
        align-content: start;
        min-height: auto;
        padding-top: 34px;
    }

    .phone-shell {
        width: min(300px, 78vw);
    }
}

.glass {
    border: 1px solid var(--glass-border);
    border-radius: 0;
}

/* Auth Pages */
.auth-container {
    display: flex; justify-content: center; align-items: center; min-height: 100vh; width: 100vw;
    background: url('https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?q=80&w=2564&auto=format&fit=crop') no-repeat center center/cover;
    position: relative;
    padding: 20px;
}
.auth-container::before { content: ''; position: absolute; inset: 0; background: rgba(15, 23, 42, 0.8); }
.auth-card { 
    position: relative; 
    width: 100%; 
    max-width: 400px; 
    padding: 30px 25px; 
    z-index: 1; 
    border-radius: 16px; 
    background: rgba(23, 33, 43, 0.95); 
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    text-align: center;
}

@media (max-width: 480px) {
    .auth-card {
        padding: 25px 20px;
    }
    .auth-card h1 {
        font-size: 2rem;
    }
}

.auth-card h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--accent-color);
}

.auth-card .subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 1rem;
}

.auth-card form {
    text-align: left;
}

.auth-card .input-group {
    margin-bottom: 20px;
}

.auth-card button[type="submit"] {
    width: 100%;
    margin-top: 10px;
    padding: 14px;
    font-size: 1rem;
}

.auth-footer {
    margin-top: 25px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    transition: 0.2s;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Main Layout */
#app { 
    display: flex; 
    height: 100vh; 
    height: 100dvh;
    width: 100%; 
    max-width: 1200px; 
    gap: 0; 
    background: var(--sidebar-bg);
}

/* Sidebar */
#sidebar { 
    width: 320px; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
}

#search-bar { padding: 20px 20px 20px; }
#chats-list { flex: 1; overflow-y: auto; padding: 0; }

.chat-item { 
    padding: 15px 20px; 
    cursor: pointer; 
    transition: 0.2s; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    position: relative;
}
.chat-item:hover { background: rgba(255, 255, 255, 0.03); }
.chat-item.active { background: #2b5278; }
.chat-item.pinned { background: rgba(56, 189, 248, 0.05); }

.chat-item-info { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.chat-item-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-username { font-size: 0.8rem; color: var(--text-secondary); }
.chat-item-last-msg { 
    font-size: 0.85rem; 
    color: var(--text-secondary); 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    margin-top: 2px;
}

.unread-dot { width: 10px; height: 10px; background: var(--accent-color); border-radius: 50%; box-shadow: 0 0 10px var(--accent-color); margin-left: 10px; flex-shrink: 0; }
.unread-dot.has-unread { animation: unreadGlow 1.4s ease-in-out infinite; }
@keyframes unreadGlow {
    0%, 100% { transform: scale(1);   box-shadow: 0 0 6px 1px rgba(56,189,248,0.6); }
    50%       { transform: scale(1.3); box-shadow: 0 0 14px 4px rgba(56,189,248,0.9); }
}

#chat-context-menu, #message-context-menu {
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    background: rgba(23, 33, 43, 0.95);
    overflow: hidden;
    animation: fadeIn 0.1s ease-out;
}

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

.search-results-title {
    padding: 15px 20px 5px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Avatar Styles */
#current-avatar-container, .chat-item-avatar-container, .avatar-settings-preview-container {
    width: 40px;
    height: 40px;
    min-width: 40px;
    margin-right: 12px;
    flex-shrink: 0;
    position: relative;
}

.chat-item-avatar-container {
    width: 48px;
    height: 48px;
}

#current-avatar-container > img, #current-avatar-container > .avatar-placeholder,
.chat-item-avatar-container > img, .chat-item-avatar-container > .avatar-placeholder,
#chat-avatar, .chat-item-avatar, #settings-avatar-preview, #chat-settings-avatar-preview, .avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    user-select: none;
    overflow: hidden;
    background: #2b5278;
}

#chat-avatar {
    width: 45px;
    height: 45px;
    margin-right: 15px;
}
#chat-avatar.hidden { display: none; }

#chat-header-info {
    display: flex;
    align-items: center;
}

.avatar-settings {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
#settings-avatar-preview, #chat-settings-avatar-preview, #profile-avatar-preview {
    width: 120px !important;
    height: 120px !important;
    min-width: 120px !important;
    min-height: 120px !important;
    border: 3px solid var(--accent-color);
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0;
    font-size: 3rem; /* For placeholder text */
}

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

#chat-members-list .member-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Status dots in list */
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    right: -2px; 
    bottom: 2px;
    display: none;
    border: 2px solid var(--sidebar-bg);
    z-index: 10;
}
.status-dot.online { 
    background-color: #4ade80; 
    display: block; 
}
#current-avatar-container .status-dot {
    right: -1px;
    bottom: 0px;
}


/* Bottom User Info */
#user-info { 
    padding: 15px 20px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--glass-border); 
}
#user-info-text { display: flex; flex-direction: column; overflow: hidden; flex: 1; }
#current-display-name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#current-user { font-size: 0.75rem; color: var(--text-secondary); }
#user-actions { display: flex; gap: 15px; align-items: center; padding-left: 10px; }
.action-link { font-size: 1.2rem; color: var(--text-secondary); cursor: pointer; text-decoration: none; transition: 0.2s; }
.action-link:hover { color: var(--accent-color); }
.logout-link { font-size: 1.1rem; color: var(--text-secondary); cursor: pointer; text-decoration: none; transition: 0.2s; }
.logout-link:hover { color: #ef4444; }

/* Chat Window */
#chat-window { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    background: var(--chat-bg);
}
#chat-header { 
    position: relative;
    padding: 15px 20px; 
    border-bottom: 1px solid var(--glass-border); 
    background: var(--chat-bg); 
    min-height: 70px; 
    display: flex; 
    align-items: center; 
}
#chat-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

#chat-status { font-size: 0.8rem; margin-top: 2px; transition: color 0.2s; }
#chat-status.online, #chat-status.typing { color: var(--accent-color); }
#chat-status.offline { color: var(--text-secondary); }

#messages { 
    flex: 1; 
    padding: 20px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    background: var(--chat-bg);
    position: relative;
}

.initial-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 1.1rem;
    opacity: 0.7;
    text-align: center;
    width: 100%;
}

.message { max-width: 75%; padding: 8px 12px; border-radius: 12px; position: relative; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.message.own { align-self: flex-end; background: var(--message-own); border-bottom-right-radius: 4px; }
.message:not(.own) { align-self: flex-start; background: var(--message-other); border-bottom-left-radius: 4px; }

.msg-meta { 
    display: flex; justify-content: flex-end; align-items: center; gap: 5px; 
    font-size: 0.65rem; margin-top: 4px; color: rgba(255, 255, 255, 0.6);
}
.time { opacity: 0.8; }
.status-icon { color: rgba(255, 255, 255, 0.5); font-weight: bold; }
.status-icon.read { color: #fff; }
.edited { font-style: italic; opacity: 0.6; margin-right: 3px; }

#typing-indicator { 
    padding: 5px 20px; 
    font-size: 0.8rem; 
    color: var(--text-secondary); 
    font-style: italic;
    height: 25px;
}
#typing-indicator.hidden { visibility: hidden; }

#message-input-container { padding: 20px; display: flex; gap: 12px; background: var(--chat-bg); border-top: 1px solid var(--glass-border); align-items: center; }
#send-button { 
    width: 44px; 
    height: 44px; 
    min-width: 44px; 
    padding: 0; 
    border-radius: 50%; 
    background: var(--message-own); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
}
#send-button:hover { background: #338dbb; transform: scale(1.05); }
#send-button svg { margin-left: -2px; margin-top: 1px; }

.icon-button { 
    background: transparent; 
    border: none; 
    color: var(--text-secondary); 
    cursor: pointer; 
    padding: 0 5px; 
    transition: 0.2s; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}
.icon-button:hover { color: var(--accent-color); }

.message-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    display: block;
    margin-bottom: 5px;
    cursor: pointer;
    transition: 0.2s;
}
.message-image:hover { opacity: 0.9; }

.message.own .message-image { border-bottom-right-radius: 0; }
.message:not(.own) .message-image { border-bottom-left-radius: 0; }


input { 
    width: 100%; 
    padding: 12px 16px; 
    background: rgba(255, 255, 255, 0.05); 
    border: 1px solid var(--glass-border); 
    border-radius: 8px; 
    color: white; 
    outline: none; 
    transition: 0.3s; 
}
input:focus { border-color: var(--accent-color); background: rgba(255, 255, 255, 0.1); }

button { 
    padding: 12px 24px; 
    background: var(--accent-color); 
    color: white; 
    border: none; 
    border-radius: 8px; 
    font-weight: 600; 
    cursor: pointer; 
    transition: 0.2s; 
}
button:hover { background: #0ea5e9; transform: translateY(-1px); }

/* Modal System */
.modal {
    position: fixed; 
    inset: 0; 
    background: rgba(0, 0, 0, 0.85);
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 1000;
    opacity: 0; 
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s;
    backdrop-filter: blur(5px);
}
.modal.active { 
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.modal-content { 
    width: 90%; 
    max-width: 450px; 
    padding: 30px; 
    border-radius: 16px; 
    background: #1c2733; 
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    opacity: 0;
}
.modal.active .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-content h3 { margin-bottom: 20px; }
.input-group { margin-bottom: 15px; }
.input-group label { display: block; margin-bottom: 5px; font-size: 0.85rem; color: var(--text-secondary); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }

.primary-action {
    background: var(--message-own) !important;
}
.primary-action:hover {
    background: #338dbb !important;
}

button.secondary { background: rgba(255, 255, 255, 0.1); }
button.secondary:hover { background: rgba(255, 255, 255, 0.15); }

/* Preview Modal Specific */
#preview-container {
    width: 100%;
    max-height: 300px;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    background: #000;
}
#preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Image Viewer (Lightbox) */
#image-viewer {
    background: rgba(0, 0, 0, 0.95);
    flex-direction: column;
    z-index: 2000; /* Higher than other modals (1000) */
}
.viewer-content {
    max-width: 90%;
    max-height: 80%;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    border-radius: 4px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    object-fit: contain;
}
.modal.active .viewer-content {
    transform: scale(1);
}
.close-viewer {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}
#viewer-caption {
    margin-top: 20px;
    color: white;
    font-size: 1.1rem;
    background: rgba(0,0,0,0.5);
    padding: 10px 20px;
    border-radius: 20px;
    max-width: 80%;
    text-align: center;
}

/* Cropping Modal Styles */
.crop-container {
    width: 100%;
    height: 350px;
    background: #000;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
}
.crop-container:active { cursor: grabbing; }

#crop-target {
    position: absolute;
    max-width: none;
    user-select: none;
    pointer-events: none;
}
.crop-overlay {
    position: absolute;
    width: 250px;
    height: 250px;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    z-index: 10;
}

.error-message { background: rgba(239, 68, 68, 0.1); color: #ef4444; padding: 10px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 15px; border: 1px solid rgba(239, 68, 68, 0.2); display: none; }

/* Animations */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Design */
@media (max-width: 768px) {
    #app {
        flex-direction: row;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        position: relative;
    }

    #sidebar {
        width: 100%;
        height: 100%;
        position: absolute;
        inset: 0;
        z-index: 20;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--sidebar-bg);
        display: flex;
        flex-direction: column;
    }

    #chat-window {
        width: 100%;
        height: 100%;
        position: absolute;
        inset: 0;
        z-index: 10;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
    }

    #app.chat-active #sidebar {
        transform: translateX(-100%);
        pointer-events: none;
    }

    #app.chat-active #chat-window {
        transform: translateX(0);
        z-index: 25;
        pointer-events: all;
    }

    #chat-header {
        padding-left: 55px; /* Increased space for back button */
    }

    .back-button {
        display: flex;
        position: absolute;
        left: 15px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 30;
        background: transparent;
        border: none;
        color: var(--text-primary);
        padding: 8px;
        cursor: pointer;
        transition: color 0.2s, background 0.2s;
        border-radius: 50%;
    }

    .back-button:hover {
        background: rgba(255, 255, 255, 0.1);
        color: var(--accent-color);
        transform: translateY(-50%); /* Maintain vertical centering without downward shift */
    }

    #chat-header-info {
        padding-left: 10px;
    }

    #message-input-container {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    #user-info {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
}

@media (min-width: 769px) {
    .back-button {
        display: none;
    }
}

.new-message {
    animation: slideUpFade 0.2s ease-out forwards;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
    70% { transform: scale(1.2); box-shadow: 0 0 0 10px rgba(56, 189, 248, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.pulse {
    animation: pulse 0.5s ease-in-out;
}

/* ============================================================
   NEW LANDING (v2) — dolus.pro
   Hero + features + CTA. Заменяет старый minimal-landing.
   ============================================================ */

body.landing-body {
    /* КРИТИЧНО: базовый body имеет display: flex (для центрирования chat-приложения),
       что ломало вертикальный layout лендинга — header, main и footer выкладывались
       в строку. Восстанавливаем нормальный block-flow. */
    display: block;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    background:
        radial-gradient(ellipse at 18% 0%, rgba(79, 168, 245, 0.22), transparent 45%),
        radial-gradient(ellipse at 82% 12%, rgba(58, 72, 237, 0.14), transparent 40%),
        linear-gradient(180deg, #0b1320 0%, #0e1621 50%, #0a111c 100%);
}

.landing-body main,
.landing-body .landing-header,
.landing-body .landing-footer {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 0 clamp(20px, 4vw, 48px);
}

.landing-body .landing-header {
    /* Специально та же специфичность (.landing-body ...) что у shared-селектора
       выше — иначе его `margin: 0 auto` перебивает margin-top. */
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 24px;
    padding-bottom: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    filter: drop-shadow(0 4px 12px rgba(58, 72, 237, 0.35));
}

.landing-nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.landing-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.15s ease;
}

.landing-nav a:hover {
    color: var(--text-primary);
}

.landing-nav .nav-cta {
    color: var(--text-primary);
    background: rgba(79, 168, 245, 0.14);
    border: 1px solid rgba(79, 168, 245, 0.32);
    padding: 9px 18px;
    border-radius: 10px;
    transition: all 0.18s ease;
}

.landing-nav .nav-cta:hover {
    background: rgba(79, 168, 245, 0.22);
    transform: translateY(-1px);
}

/* HERO */
.hero {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: clamp(40px, 6vw, 80px);
    align-items: center;
    min-height: 78vh;
    padding-top: clamp(40px, 6vw, 80px);
    padding-bottom: clamp(60px, 8vw, 100px);
}

.hero-copy {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: flex-start;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(79, 168, 245, 0.12);
    border: 1px solid rgba(79, 168, 245, 0.28);
    color: #7AC3FF;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.hero h1 {
    font-size: clamp(2.4rem, 5.5vw, 4rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.025em;
    margin: 0;
}

.hero h1 .accent {
    background: linear-gradient(120deg, #4FA8F5 0%, #3a48ed 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lede {
    font-size: 1.15rem;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 52px;
    padding: 0 24px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 0.98rem;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn.primary {
    background: linear-gradient(135deg, #4FA8F5 0%, #3390EC 60%, #1F6FC9 100%);
    color: #fff;
    box-shadow: 0 12px 32px rgba(51, 144, 236, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(51, 144, 236, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn.ghost {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.1);
}

.btn.ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.btn.big {
    height: 60px;
    padding: 0 32px;
    font-size: 1.05rem;
    border-radius: 16px;
}

.trust {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 18px 28px;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.trust li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.trust span {
    font-size: 1.05rem;
}

/* PHONE MOCKUP */
.hero-phone {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.phone {
    position: relative;
    width: min(340px, 88vw);
    aspect-ratio: 0.49;
    background: #0a0f17;
    border-radius: 44px;
    padding: 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.03) inset,
        0 60px 120px -20px rgba(0, 0, 0, 0.6),
        0 25px 60px -10px rgba(51, 144, 236, 0.2);
    z-index: 2;
}

.phone-notch {
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 22px;
    background: #050a13;
    border-radius: 12px;
    z-index: 3;
}

.phone-glow {
    position: absolute;
    inset: -10%;
    background: radial-gradient(circle at 50% 50%, rgba(79, 168, 245, 0.28), transparent 55%);
    filter: blur(40px);
    z-index: 1;
    pointer-events: none;
}

.phone-screen {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0e1621 0%, #111b28 100%);
    border-radius: 32px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 38px 14px 12px;
    background: rgba(23, 33, 43, 0.7);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-back {
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-back svg { width: 20px; height: 20px; }
.chat-id { flex: 1; display: flex; flex-direction: column; }
.chat-id strong { font-size: 0.95rem; color: var(--text-primary); }
.chat-id small { font-size: 0.72rem; color: #4FA8F5; }

.chat-av {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7AC3FF, #1F6FC9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
}

.chat-area {
    flex: 1;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.date-chip {
    align-self: center;
    background: rgba(0, 0, 0, 0.32);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.7rem;
    padding: 3px 12px;
    border-radius: 12px;
    margin-bottom: 4px;
    font-weight: 600;
}

.bubble {
    max-width: 75%;
    padding: 8px 12px;
    font-size: 0.82rem;
    line-height: 1.4;
    border-radius: 16px;
    word-wrap: break-word;
}

.bubble.in {
    align-self: flex-start;
    background: #212d3b;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.bubble.out {
    align-self: flex-end;
    background: linear-gradient(135deg, #4FA8F5 0%, #3390EC 60%, #1F6FC9 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.bubble.voice {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 10px 12px;
    max-width: 88%;
    background: #212d3b;
}

.bubble.voice .play {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #4FA8F5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.bubble.voice .play svg {
    width: 14px;
    height: 14px;
}

.bubble.voice .bars {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 18px;
}

.bubble.voice .bars i {
    /* display: block нужен — без него <i> остаётся inline и flex его не растягивает,
       waveform получается невидимым (что было на скриншоте). */
    display: block;
    flex: 1;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 2px;
    min-width: 2px;
}
.bubble.voice .bars i:nth-child(1)  { height: 30%; }
.bubble.voice .bars i:nth-child(2)  { height: 60%; }
.bubble.voice .bars i:nth-child(3)  { height: 40%; }
.bubble.voice .bars i:nth-child(4)  { height: 85%; }
.bubble.voice .bars i:nth-child(5)  { height: 55%; }
.bubble.voice .bars i:nth-child(6)  { height: 90%; }
.bubble.voice .bars i:nth-child(7)  { height: 45%; }
.bubble.voice .bars i:nth-child(8)  { height: 70%; }
.bubble.voice .bars i:nth-child(9)  { height: 30%; }
.bubble.voice .bars i:nth-child(10) { height: 55%; }
.bubble.voice .bars i:nth-child(11) { height: 80%; }
.bubble.voice .bars i:nth-child(12) { height: 40%; }
.bubble.voice .bars i:nth-child(13) { height: 65%; }
.bubble.voice .bars i:nth-child(14) { height: 50%; }
.bubble.voice .bars i:nth-child(15) { height: 75%; }
.bubble.voice .bars i:nth-child(16) { height: 35%; }
.bubble.voice .bars i:nth-child(17) { height: 60%; }
.bubble.voice .bars i:nth-child(18) { height: 45%; }

.bubble.voice small {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 10px 14px;
    background: #212d3b;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    animation: typingBlink 1.2s infinite;
}

.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBlink {
    0%, 60%, 100% { opacity: 0.35; transform: scale(0.85); }
    30% { opacity: 1; transform: scale(1); }
}

.chat-composer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    background: rgba(23, 33, 43, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-composer .emoji,
.chat-composer .attach,
.chat-composer .mic {
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-composer .emoji svg,
.chat-composer .attach svg,
.chat-composer .mic svg {
    width: 18px;
    height: 18px;
}

.chat-composer .placeholder {
    flex: 1;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
}

/* FEATURES */
.features {
    padding: clamp(60px, 9vw, 120px) 0;
    text-align: center;
}

.section-title {
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
}

.section-sub {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0 0 56px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    text-align: left;
}

.feature {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 28px;
    transition: all 0.25s ease;
}

.feature:hover {
    background: rgba(255, 255, 255, 0.045);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-4px);
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--c1), var(--c2));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    box-shadow: 0 8px 24px -8px var(--c2);
}

.feature-icon svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.feature h3 {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.feature p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.55;
}

/* CTA */
.cta {
    padding: 0 0 clamp(60px, 8vw, 100px);
}

.cta-card {
    background:
        radial-gradient(circle at 30% 0%, rgba(79, 168, 245, 0.16), transparent 60%),
        linear-gradient(135deg, rgba(31, 111, 201, 0.20) 0%, rgba(58, 72, 237, 0.18) 100%);
    border: 1px solid rgba(79, 168, 245, 0.22);
    border-radius: 28px;
    padding: clamp(40px, 6vw, 64px);
    text-align: center;
    backdrop-filter: blur(12px);
}

.cta-card h2 {
    font-size: clamp(1.8rem, 3.5vw, 2.4rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
}

.cta-card p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin: 0 0 28px;
}

.cta-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
}

.cta .fine {
    margin: 18px 0 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
}

/* FOOTER */
.landing-body .landing-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    /* Шапочный shared-селектор задаёт left/right через padding-shorthand —
       поэтому здесь специально та же специфичность (.landing-body .landing-footer)
       и явный override верт/гориз отступов. */
    padding: 20px clamp(20px, 4vw, 48px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.footer-links a:hover { color: var(--text-primary); }

/* MOBILE */
@media (max-width: 880px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 50px;
        min-height: auto;
        padding-top: 80px;
        padding-bottom: 60px;
    }

    /* На мобильной phone-mockup скрываем — он занимает экран и не несёт
       информации сверх hero-копии. */
    .hero-phone { display: none; }
    .landing-nav a:not(.nav-cta) { display: none; }

    .hero-actions { width: 100%; flex-direction: column; }
    .hero-actions .btn { width: 100%; }

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

    .landing-footer { flex-direction: column; gap: 14px; }

    /* На мобильной в CTA-блоке оставляем только основную кнопку «Скачать .apk» —
       Web-версия избыточна на телефоне: пользователь уже на сайте через мобильный браузер. */
    .cta-buttons .btn.ghost { display: none; }
}
