/* ========== GOOGLE FONTS ========== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&family=Inter+Tight:wght@700;900&display=swap');

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

/* ========== MEMPHIS TOKENS ========== */
:root {
    --m-yellow:  #FFE135;
    --m-pink:    #FF5FA0;
    --m-teal:    #00C2C7;
    --m-orange:  #FF6B35;
    --m-purple:  #8B5CF6;
    --m-lime:    #AAED3B;
    --m-dark:    #1A1A1A;
    --m-surface: #FFFFFF;
    --m-surface2:#F5F0E8;
    --m-shadow:  rgba(0,0,0,0.22);
}

/* ========== APP ========== */
body {
    font-family: 'Inter', 'Arial', sans-serif;
    background: var(--m-surface2);
    color: var(--m-dark);
    overflow: hidden;
}

#app {
    width: 100%;
    height: 100vh;
    position: relative;
    background-image:
        radial-gradient(circle, var(--m-dark) 1.5px, transparent 1.5px),
        radial-gradient(circle, var(--m-dark) 1.5px, transparent 1.5px);
    background-size: 24px 24px, 24px 24px;
    background-position: 0 0, 12px 12px;
}

/* ========== LOGIN ========== */
.form-container {
    max-width: 380px;
    width: 92%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--m-surface);
    border: 4px solid var(--m-dark);
    border-radius: 28px;
    padding: 32px;
    text-align: center;
    box-shadow: none;
}

.form-container h2 {
    font-size: 22px;
    font-weight: 900;
    font-family: 'Inter Tight', 'Arial Black', sans-serif;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 24px;
    color: var(--m-dark);
    background: var(--m-yellow);
    display: inline-block;
    padding: 4px 14px;
    transform: rotate(-1deg);
}

.form-container input,
.form-container button {
    width: 100%;
    padding: 12px 14px;
    margin-top: 10px;
    border: 3px solid var(--m-dark);
    border-radius: 50px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
}

.form-container input {
    background: var(--m-surface2);
    color: var(--m-dark);
}

.form-container input:focus {
    outline: none;
    background: #fffbe0;
    border-color: var(--m-pink);
}

.form-container button {
    background: var(--m-yellow);
    color: var(--m-dark);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: transform .1s, box-shadow .1s, background .15s;
    box-shadow: none;
    margin-top: 14px;
}

.form-container button:hover {
    background: var(--m-pink);
    color: #fff;
}

.form-container button:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

.form-container hr {
    margin: 20px 0;
    border: none;
    border-top: 3px dashed var(--m-dark);
}

.error {
    margin-top: 12px;
    color: var(--m-orange);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ========== MAIN UI ========== */
#mainUI {
    width: 100%;
    height: 100%;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* ========== PANEL BASE ========== */
.contacts-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--m-surface);
    border-right: 4px solid var(--m-dark);
    border-radius: 0;
    z-index: 10;
    transition: transform .3s ease;
}

.contacts-panel.slide-left {
    transform: translateX(-100%);
}

/* ========== CHAT PANEL ========== */
.chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--m-surface2);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 20px,
        rgba(0,0,0,.03) 20px,
        rgba(0,0,0,.03) 21px
    );
    z-index: 20;
    transform: translateX(100%);
    transition: transform .3s ease;
}

.chat-panel.open {
    transform: translateX(0);
}

/* ========== WEATHER/NEWS INPUT STYLES ========== */
.chat-panel.weather-mode .attach-btn,
.chat-panel.news-mode .attach-btn,
.chat-panel.cities-mode .attach-btn {
    display: none !important;
}

.chat-panel.weather-mode .chat-input,
.chat-panel.news-mode .chat-input,
.chat-panel.cities-mode .chat-input {
    display: flex;
    gap: 0;
    padding: 12px 16px;
    border-top: 4px solid var(--m-dark);
    background: var(--m-surface);
}

.chat-panel.weather-mode .chat-input input,
.chat-panel.news-mode .chat-input input,
.chat-panel.cities-mode .chat-input input {
    flex: 1;
    padding: 12px 18px;
    border: 3px solid var(--m-dark);
    border-radius: 50px;
    background: var(--m-surface2);
    color: var(--m-dark);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    min-width: 0;
    outline: none;
    transition: background 0.15s, border-color 0.15s;
}

.chat-panel.weather-mode .chat-input input:focus,
.chat-panel.news-mode .chat-input input:focus,
.chat-panel.cities-mode .chat-input input:focus {
    background: #fffbe0;
    border-color: var(--m-pink);
}

.chat-panel.weather-mode .chat-input input::placeholder,
.chat-panel.news-mode .chat-input input::placeholder,
.chat-panel.cities-mode .chat-input input::placeholder {
    color: #aaa;
    font-weight: 400;
}

.chat-panel.weather-mode .chat-input button,
.chat-panel.news-mode .chat-input button,
.chat-panel.cities-mode .chat-input button {
    padding: 12px 24px;
    margin-left: 12px;
    border: 3px solid var(--m-dark);
    border-radius: 50px;
    background: var(--m-pink);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
    box-shadow: none;
}

.chat-panel.weather-mode .chat-input button:hover,
.chat-panel.news-mode .chat-input button:hover,
.chat-panel.cities-mode .chat-input button:hover {
    background: var(--m-orange);
}

.chat-panel.weather-mode .chat-input button:active,
.chat-panel.news-mode .chat-input button:active,
.chat-panel.cities-mode .chat-input button:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.chat-panel:not(.open):not(.cities-mode) .chat-input,
.chat-panel:not(.open) .attach-btn {
    display: none !important;
}

/* ========== ДЕСКТОПНАЯ ВЕРСИЯ ========== */
@media (min-width: 769px) {
    #mainUI {
        display: flex;
        flex-direction: row;

        width: 100%;
        height: 100%;
    }

    .contacts-panel {
        position: relative;
        inset: auto;
        width: 350px;
        min-width: 350px;
        max-width: 350px;
        height: 100vh;
        flex-shrink: 0;
        z-index: 1;
        transform: none !important;
        border-right: 4px solid var(--m-dark);
        overflow: hidden;
    }
    
    .chat-panel {
        position: relative;
        inset: auto;
        flex: 0 0 600px;
        width: 600px;
        min-width: 600px;
        max-width: 600px;
        height: 100vh;
        display: flex;
        flex-direction: column;
        z-index: 1;
        transform: none !important;
        margin-left: 0;
        border-left: none;
        overflow: hidden;
    }
    
    .chat-panel.open {
        transform: none;
        display: flex;
    }
    
    .back-btn {
        display: none !important;
    }
    
    .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }
    
    .chat-input {
        flex-shrink: 0;
        margin-top: auto;
    }
    
    .chat-panel .chat-input {
        display: flex !important;
    }
    
    .chat-panel:not(.weather-mode):not(.news-mode):not(.cities-mode):not(.open) .chat-input {
        display: none !important;
    }
    
    .chat-panel.weather-mode .chat-input,
    .chat-panel.news-mode .chat-input,
    .chat-panel.cities-mode .chat-input {
        display: flex !important;
        padding: 16px 20px;
    }
    
    .chat-panel.weather-mode .chat-input input,
    .chat-panel.news-mode .chat-input input,
    .chat-panel.cities-mode .chat-input input {
        padding: 14px 20px;
        font-size: 14px;
    }
    
    .chat-panel.weather-mode .chat-input button,
    .chat-panel.news-mode .chat-input button,
    .chat-panel.cities-mode .chat-input button {
        padding: 14px 28px;
        font-size: 13px;
    }
    
    .search-bar {
        padding: 10px 12px;
    }
    
    .search-bar input {
        font-size: 13px;
        padding: 8px 14px;
    }
    
    .search-bar button {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .search-card {
        margin: 6px 10px;
        padding: 8px 12px;
    }
    
    .search-avatar {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 13px;
    }
    
    .search-name {
        font-size: 12px;
    }
    
    .search-email {
        font-size: 10px;
    }
    
    .search-add-btn {
        padding: 4px 12px;
        font-size: 10px;
    }

    .chat-panel .chat-messages:empty::before {
        content: "✨ Select a contact to start messaging";
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        font-size: 14px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 1px;
        text-align: center;
        padding: 20px;
        color: var(--m-dark);
        opacity: 0.5;
    }
}

/* ========== МОБИЛЬНАЯ ВЕРСИЯ ========== */
@media (max-width: 768px) {
    .contacts-panel {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        overflow-y: auto;
    }
    
    .contacts-panel.slide-left {
        transform: translateX(-100%);
    }
    
    .chat-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        transform: translateX(100%);
        transition: transform .3s ease;
        z-index: 30;
        background: var(--m-surface2);
    }
    
    .chat-panel.open {
        transform: translateX(0);
    }
    
    .chat-panel:not(.open) .chat-input {
        display: none !important;
    }
    
    .chat-header {
        flex-shrink: 0;
    }
    
    .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
    }
    
    .chat-input {
        flex-shrink: 0;
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: var(--m-surface);
        border-top: 4px solid var(--m-dark);
        display: flex;
        gap: 0;
    }
    
    .chat-input .attach-btn {
        padding: 12px 14px;
        border: 3px solid var(--m-dark);
        border-right: none;
        border-radius: 50px 0 0 50px;
        background: var(--m-lime);
        font-size: 18px;
    }
    
    .chat-input textarea {
        flex: 1;
        padding: 12px 14px;
        font-size: 16px;
        min-height: 48px;
        border: 3px solid var(--m-dark);
        border-left: none;
        border-right: none;
        border-radius: 0;
        background: var(--m-surface2);
    }
    
    .chat-input button {
        padding: 12px 20px;
        min-height: 48px;
        min-width: 72px;
        border: 3px solid var(--m-dark);
        border-left: none;
        border-radius: 0 50px 50px 0;
        background: var(--m-pink);
        color: #fff;
        font-size: 13px;
        font-weight: 900;
    }
    
    .chat-panel.weather-mode .chat-input,
    .chat-panel.news-mode .chat-input,
    .chat-panel.cities-mode .chat-input {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: var(--m-surface);
        border-top: 4px solid var(--m-dark);
    }
    
    .chat-panel.weather-mode .chat-input input,
    .chat-panel.news-mode .chat-input input,
    .chat-panel.cities-mode .chat-input input {
        padding: 12px 18px;
        font-size: 16px;
        min-height: 48px;
        border: 3px solid var(--m-dark);
        border-radius: 50px;
    }
    
    .chat-panel.weather-mode .chat-input button,
    .chat-panel.news-mode .chat-input button,
    .chat-panel.cities-mode .chat-input button {
        padding: 12px 20px;
        min-height: 48px;
        margin-left: 10px;
        border-radius: 50px;
        font-size: 13px;
    }
    
    .back-btn {
        display: inline-block;
        margin-right: 12px;
        border: 2px solid var(--m-teal);
        border-radius: 50px;
        background: transparent;
        color: var(--m-teal);
        font-size: 20px;
        cursor: pointer;
        padding: 2px 10px;
    }

    .top-buttons {
        gap: 8px;
        padding: 12px 8px;
    }

    .circle-btn {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
}

/* ========== HEADER ========== */
.header {
    padding: 0 20px;
    background: var(--m-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    height: 60px;
    flex-shrink: 0;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        var(--m-yellow) 0, var(--m-yellow) 12px,
        var(--m-pink)   12px, var(--m-pink)   24px,
        var(--m-teal)   24px, var(--m-teal)   36px
    );
}

.header span {
    font-size: 14px;
    font-weight: 900;
    font-family: 'Inter Tight', 'Arial Black', sans-serif;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--m-yellow);
}

.logout-btn {
    border: 2px solid var(--m-yellow);
    border-radius: 50px;
    background: transparent;
    color: var(--m-yellow);
    padding: 5px 14px;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background .15s, color .15s;
}

.logout-btn:hover {
    background: var(--m-yellow);
    color: var(--m-dark);
}

/* ========== TOP BUTTONS ========== */
.top-buttons {
    display: flex;
    gap: 16px;
    padding: 18px 20px;
    justify-content: center;
    align-items: center;
    background: var(--m-surface2);
    border-bottom: 3px solid var(--m-dark);
}

.circle-btn {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border: 3px solid var(--m-dark);
    border-radius: 50%;
    background: var(--m-yellow);
    color: var(--m-dark);
    font-size: 20px;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.circle-btn:nth-child(2) {
    background: var(--m-teal);
}

.circle-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: none;
}

.circle-btn:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

/* ========== REQUESTS BADGE ========== */
.requests-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--m-pink);
    color: #fff;
    border: 2px solid var(--m-dark);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== CONTACTS LIST ========== */
.contacts-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    background: var(--m-surface);
}

.contacts-list::-webkit-scrollbar { width: 4px; }
.contacts-list::-webkit-scrollbar-thumb { background: var(--m-dark); opacity: .3; border-radius: 2px; }

.contacts-self-row {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 10px 14px;
    border-bottom: 3px solid var(--m-dark);
    background: var(--m-yellow);
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
    min-height: 68px;
}

.contacts-self-row:hover { background: var(--m-lime); }

.contacts-self-avatar {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 50%;
    border: 3px solid var(--m-dark);
    background: var(--m-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 900;
    color: var(--m-yellow);
    text-transform: uppercase;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.contacts-self-avatar img {
    width: 100%; height: 100%;
    object-fit: cover; border-radius: 50%;
    position: absolute; inset: 0;
}

.contacts-self-name {
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--m-dark);
}

.contacts-self-sub {
    font-size: 10px;
    font-weight: 700;
    color: var(--m-dark);
    opacity: .5;
    margin-top: 2px;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 8px 14px;
    min-height: 72px;
    border-bottom: 1.5px solid rgba(0,0,0,.07);
    cursor: pointer;
    transition: background .1s;
    position: relative;
    background: var(--m-surface);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.contact-card:last-child { border-bottom: none; }

.contact-card:hover  { background: var(--m-surface2); }

.contact-card.active {
    background: color-mix(in srgb, var(--m-teal) 18%, var(--m-surface));
    border-left: 4px solid var(--m-teal);
}

.contact-avatar {
    width: 54px;
    height: 54px;
    min-width: 54px;
    border-radius: 50%;
    border: 3px solid var(--m-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    font-weight: 900;
    color: var(--m-dark);
    text-transform: uppercase;
    position: relative;
    flex-shrink: 0;
}

.contact-avatar img {
    width: 100%; height: 100%;
    object-fit: cover; border-radius: 50%;
    position: absolute; inset: 0;
    overflow: hidden;
}

.contact-status-dot {
    position: absolute;
    bottom: -2px; right: -2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2.5px solid var(--m-surface);
    background: #c0c0c0;
    pointer-events: none;
    z-index: 10;
}

.contact-status-dot.online {
    background: #4cd964;
    border-color: var(--m-surface);
    box-shadow: 0 0 0 1.5px var(--m-dark);
}

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

.contact-name-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
}

.contact-name {
    font-size: 14px;
    font-weight: 900;
    color: var(--m-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: .3px;
    text-transform: uppercase;
}

.contact-time {
    font-size: 11px;
    font-weight: 700;
    color: var(--m-dark);
    opacity: .4;
    white-space: nowrap;
    flex-shrink: 0;
    font-style: normal;
}

.contact-preview-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
}

.contact-last-msg {
    font-size: 12px;
    font-weight: 600;
    color: var(--m-dark);
    opacity: .55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.contact-unread {
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    background: var(--m-pink);
    color: #fff;
    border: 2.5px solid var(--m-dark);
    font-size: 10px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
    box-shadow: 2px 2px 0 var(--m-dark);
    letter-spacing: 0;
}

.orbit-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--m-dark);
    font-size: 13px;
    font-weight: 700;
    opacity: .6;
}

.orbit-avatar-img {
    width: 100%; height: 100%;
    object-fit: cover; border-radius: 50%;
    position: absolute; inset: 0;
    pointer-events: none;
}

/* ========== CHAT HEADER ========== */
.chat-header {
    padding: 0 20px;
    background: var(--m-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 900;
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--m-surface);
    position: relative;
    flex-shrink: 0;
    height: 60px;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        var(--m-teal)   0, var(--m-teal)   12px,
        var(--m-orange) 12px, var(--m-orange) 24px,
        var(--m-lime)   24px, var(--m-lime)   36px
    );
}

.chat-header button {
    border: 2px solid var(--m-orange);
    border-radius: 50px;
    background: transparent;
    color: var(--m-orange);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 12px;
    transition: background .15s, color .15s;
}

.chat-header button:hover {
    background: var(--m-orange);
    color: #fff;
}

/* ========== MESSAGES ========== */
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--m-dark); }

.message {
    max-width: 72%;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 400;
    font-family: 'Inter', 'Arial', sans-serif;
    word-wrap: break-word;
    border-radius: 20px;
    border: 3px solid var(--m-dark);
    line-height: 1.55;
}

.message.own {
    align-self: flex-end;
    background: var(--m-yellow);
    color: var(--m-dark);
    box-shadow: none;
    border-bottom-right-radius: 6px;
}

.message.other {
    align-self: flex-start;
    background: var(--m-surface);
    color: var(--m-dark);
    box-shadow: none;
    border-bottom-left-radius: 6px;
}

.message-time {
    margin-top: 4px;
    font-size: 10px;
    font-weight: 900;
    opacity: .55;
    text-align: right;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ========== CHAT INPUT ========== */
.chat-input {
    display: flex;
    gap: 0;
    padding: 12px 16px;
    border-top: 4px solid var(--m-dark);
    background: var(--m-surface);
    flex-shrink: 0;
}

.chat-input .attach-btn {
    padding: 12px 14px;
    border: 3px solid var(--m-dark);
    border-right: none;
    border-radius: 50px 0 0 50px;
    background: var(--m-lime);
    color: var(--m-dark);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background .15s;
    flex-shrink: 0;
}

.chat-input .attach-btn:hover { background: var(--m-teal); }
.chat-input .attach-btn:active { transform: translate(2px,2px); box-shadow: none; }

.chat-input textarea {
    flex: 1;
    padding: 12px 14px;
    border: 3px solid var(--m-dark);
    border-left: none;
    border-right: none;
    background: var(--m-surface2);
    color: var(--m-dark);
    font-family: 'Inter', 'Arial', sans-serif;
    font-size: 15px;
    font-weight: 400;
    resize: none;
    overflow-y: hidden;
    line-height: 1.5;
    min-height: 48px;
    max-height: 150px;
    transition: height 0.05s ease;
}

.chat-input textarea:focus {
    outline: none;
    background: #fffbe0;
}

.chat-input textarea::placeholder {
    color: #aaa;
    font-weight: 400;
}

.chat-input button {
    padding: 12px 20px;
    border: 3px solid var(--m-dark);
    border-left: none;
    border-radius: 0 50px 50px 0;
    background: var(--m-pink);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background .15s;
    flex-shrink: 0;
}

.chat-input button:hover { background: var(--m-orange); }
.chat-input button:active { transform: translate(2px, 2px); box-shadow: none; }

/* ========== BACK BUTTON ========== */
.back-btn {
    margin-right: 12px;
    border: 2px solid var(--m-teal);
    border-radius: 50px;
    background: transparent;
    color: var(--m-teal);
    font-size: 20px;
    cursor: pointer;
    padding: 2px 10px;
    font-family: inherit;
    font-weight: 900;
    transition: background .15s, color .15s;
}

.back-btn:hover {
    background: var(--m-teal);
    color: var(--m-dark);
}

/* ========== WEATHER / NEWS ========== */
.weather-container,
.news-container {
    padding: 16px;
}

.weather-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* In weather/news mode remove extra padding so content scrolls naturally */
.chat-panel.weather-mode .chat-messages,
.chat-panel.news-mode .chat-messages {
    padding: 0;
    gap: 0;
}
.chat-panel.weather-mode .chat-messages .weather-container {
    width: 100%;
    box-sizing: border-box;
}

.weather-current {
    background: var(--m-surface);
    border: 4px solid var(--m-dark);
    border-radius: 24px;
    padding: 30px;
    text-align: center;
    box-shadow: none;
}

.news-item {
    margin-bottom: 14px;
    background: var(--m-surface);
    border: 3px solid var(--m-dark);
    border-radius: 18px;
    padding: 16px 16px 16px 22px;
    box-shadow: none;
    border-left: 6px solid var(--m-teal);
}

.news-item h3 {
    color: var(--m-dark);
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.news-item p {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
}

.news-item small {
    display: block;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.news-item--has-thumb {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 0;
    overflow: hidden;
}

.news-item__thumb-wrap {
    flex-shrink: 0;
    width: 110px;
    align-self: stretch;
    overflow: hidden;
    border-radius: 12px 0 0 12px;
    border-right: 3px solid var(--m-dark);
    background: var(--m-surface2);
}

.news-item__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity .2s;
}

.news-item--has-thumb .news-item__body {
    flex: 1;
    min-width: 0;
    padding: 14px 16px 14px 0;
}

.news-item:not(.news-item--has-thumb) .news-item__body {
    padding: 0;
}

.news-item:not(.news-item--has-thumb) {
    padding: 16px 16px 16px 22px;
}

@media (max-width: 480px) {
    .news-item--has-thumb {
        flex-direction: column;
        gap: 0;
    }

    .news-item__thumb-wrap {
        width: 100%;
        height: 140px;
        align-self: auto;
        border-radius: 12px 12px 0 0;
        border-right: none;
        border-bottom: 3px solid var(--m-dark);
    }

    .news-item--has-thumb .news-item__body {
        padding: 12px 14px;
    }
}

.news-load-more {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 12px;
    border: 3px solid var(--m-dark);
    border-radius: 50px;
    background: var(--m-yellow);
    color: var(--m-dark);
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background .15s;
}
.news-load-more:hover  { background: var(--m-teal); color: #fff; }
.news-load-more:active { transform: translateY(1px); }

.news-end-note {
    margin-top: 14px;
    padding: 10px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-top: 2px dashed var(--m-dark);
    opacity: 0.5;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--m-dark);
    color: var(--m-yellow);
    padding: 10px 24px;
    border: 3px solid var(--m-yellow);
    border-radius: 50px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: none;
    z-index: 1000;
}

/* ========== SEARCH BAR ========== */
.search-bar {
    display: flex;
    gap: 0;
    padding: 12px 14px;
    padding-right: 18px;
    border-bottom: 3px solid var(--m-dark);
    background: var(--m-surface2);
}

.search-bar input {
    flex: 1;
    padding: 9px 16px;
    border: 3px solid var(--m-dark);
    border-right: none;
    border-radius: 50px 0 0 50px;
    background: var(--m-surface);
    color: var(--m-dark);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
}

.search-bar input:focus {
    outline: none;
    background: #fffbe0;
}

.search-bar input::placeholder {
    color: #aaa;
    font-weight: 400;
}

.search-bar button {
    padding: 9px 14px;
    border: 3px solid var(--m-dark);
    border-radius: 0 50px 50px 0;
    background: var(--m-teal);
    color: var(--m-dark);
    font-size: 16px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 900;
    transition: background .15s, transform .1s;
    box-shadow: none;
}

.search-bar button:hover  { background: var(--m-lime); }
.search-bar button:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

/* ========== SEARCH RESULT CARD ========== */
#searchResult {
    border-bottom: 3px solid var(--m-dark);
}

.search-loading,
.search-error {
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.search-loading { color: #888; }
.search-error   { color: var(--m-orange); }

.search-card {
    padding: 12px 14px;
    background: var(--m-surface);
    border-radius: 16px;
    margin: 8px 12px;
    border: 3px solid var(--m-dark);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.search-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.search-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: 3px solid var(--m-dark);
    border-radius: 50%;
    background: var(--m-yellow);
    color: var(--m-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 900;
}

.search-name {
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-email {
    font-size: 11px;
    font-weight: 700;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-add-btn {
    padding: 6px 16px;
    border: 3px solid var(--m-dark);
    border-radius: 50px;
    background: var(--m-yellow);
    color: var(--m-dark);
    font-family: inherit;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
    transition: background .15s, transform .1s;
}

.search-add-btn:hover  { background: var(--m-lime); }
.search-add-btn:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.search-tag {
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 4px 12px;
    border: 2px solid var(--m-dark);
    border-radius: 50px;
    white-space: nowrap;
}

.search-tag--friends { background: var(--m-lime);  color: var(--m-dark); }
.search-tag--pending { background: var(--m-surface2); color: #888; }

/* ========== REQUESTS PANEL ========== */
.requests-container {
    padding: 20px;
}

.requests-container h2 {
    font-size: 18px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 20px;
    background: var(--m-dark);
    color: var(--m-yellow);
    padding: 6px 18px;
    border-radius: 50px;
    display: inline-block;
}

.weather-container h2,
.news-container h2 {
    font-size: 18px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 20px;
    background: var(--m-dark);
    color: var(--m-yellow);
    padding: 6px 18px;
    border-radius: 50px;
    display: inline-block;
}

.requests-empty {
    padding: 40px 20px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #aaa;
}

.request-card {
    background: var(--m-surface);
    border: 3px solid var(--m-dark);
    border-radius: 20px;
    padding: 14px 16px;
    margin-bottom: 14px;
    box-shadow: none;
}

.request-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

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

.req-btn {
    flex: 1;
    padding: 8px;
    border: 3px solid var(--m-dark);
    border-radius: 50px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
    box-shadow: none;
    transition: transform .1s, box-shadow .1s;
}

.req-btn:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.req-btn--accept  { background: var(--m-lime);  color: var(--m-dark); }
.req-btn--decline { background: var(--m-orange); color: #fff; }

.req-btn--accept:hover  { background: var(--m-teal); }
.req-btn--decline:hover { background: var(--m-pink); }

.request-done {
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #888;
    text-align: center;
    padding: 4px 0;
}

/* ========== MEDIA IN MESSAGE ========== */
.msg-image-wrap { max-width: 260px; }
.msg-image {
    display: block;
    max-width: 100%;
    max-height: 300px;
    border: 3px solid var(--m-dark);
    border-radius: 12px;
    cursor: zoom-in;
    object-fit: cover;
}
.msg-image:hover { opacity: .88; }

.msg-video-wrap { max-width: 280px; }
.msg-video {
    display: block;
    max-width: 100%;
    max-height: 300px;
    border: 3px solid var(--m-dark);
    border-radius: 12px;
}

.msg-file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 3px solid var(--m-dark);
    border-radius: 12px;
    background: var(--m-surface2);
    color: var(--m-dark);
    text-decoration: none;
    min-width: 180px;
    max-width: 260px;
    box-shadow: none;
    transition: background .15s;
}
.msg-file-card:hover { background: var(--m-yellow); }
.msg-file-icon { font-size: 26px; flex-shrink: 0; }
.msg-file-info { flex: 1; overflow: hidden; }
.msg-file-name {
    display: block;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-file-size {
    display: block;
    font-size: 10px;
    font-weight: 600;
    opacity: .6;
    margin-top: 2px;
    text-transform: uppercase;
}
.msg-file-dl { font-size: 16px; flex-shrink: 0; opacity: .7; }

.msg-caption {
    margin-top: 5px;
    font-size: 12px;
    font-weight: 600;
    opacity: .75;
    word-break: break-word;
}

/* ========== PROFILE MODAL ========== */
.profile-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.profile-modal {
    background: var(--m-surface);
    border: 4px solid var(--m-dark);
    border-radius: 16px;
    box-shadow: none;
    width: 100%;
    max-width: 360px;
    overflow: hidden;
}

.profile-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--m-yellow);
    border-bottom: 3px solid var(--m-dark);
    font-size: 15px;
    font-weight: 900;
    color: var(--m-dark);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.profile-close-btn {
    background: transparent;
    border: 2px solid var(--m-dark);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--m-dark);
    font-weight: 900;
    transition: background .15s;
}
.profile-close-btn:hover { background: var(--m-dark); color: var(--m-yellow); }

.profile-avatar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px 16px;
    gap: 10px;
    position: relative;
}

.profile-avatar-img {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 4px solid var(--m-dark);
    object-fit: cover;
    box-shadow: none;
}

.profile-avatar-placeholder {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 4px solid var(--m-dark);
    background: var(--m-yellow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 900;
    color: var(--m-dark);
    box-shadow: none;
}

.profile-avatar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 18px;
    background: var(--m-surface2);
    border: 3px solid var(--m-dark);
    border-radius: 50px;
    font-size: 13px;
    font-weight: 800;
    color: var(--m-dark);
    cursor: pointer;
    box-shadow: none;
    transition: background .15s, transform .1s;
}
.profile-avatar-btn:hover { background: var(--m-teal); color: #fff; }
.profile-avatar-btn:active { transform: translate(2px,2px); box-shadow: none; }

.profile-field-error {
    font-size: 11px;
    font-weight: 700;
    color: #d32;
    min-height: 16px;
    text-align: center;
}

.profile-fields {
    padding: 4px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.profile-field label {
    display: block;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--m-dark);
    opacity: .5;
    margin-bottom: 5px;
}

.profile-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--m-dark);
    padding: 8px 12px;
    background: var(--m-surface2);
    border: 2px solid var(--m-dark);
    border-radius: 8px;
    word-break: break-all;
}

.profile-phone-input {
    flex: 1;
    background: var(--m-surface2);
    border: 3px solid var(--m-dark);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    color: var(--m-dark);
    outline: none;
    transition: border-color .15s;
}
.profile-phone-input:focus { border-color: var(--m-teal); }

.profile-save-btn {
    background: var(--m-lime);
    border: 3px solid var(--m-dark);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 900;
    font-family: inherit;
    color: var(--m-dark);
    cursor: pointer;
    box-shadow: none;
    white-space: nowrap;
    transition: background .15s;
}
.profile-save-btn:hover { background: var(--m-teal); color: #fff; }

/* ========== COLOR SCHEMES ========== */
[data-scheme="1"] {
    --m-yellow:  #F0FF00;
    --m-pink:    #FF00CC;
    --m-teal:    #00FFEA;
    --m-orange:  #FF6600;
    --m-purple:  #CC00FF;
    --m-lime:    #00FF66;
    --m-dark:    #0A0A0A;
    --m-surface: #1E1E2E;
    --m-surface2:#2A2A40;
}

[data-scheme="2"] {
    --m-yellow:  #FFD6A5;
    --m-pink:    #FFADBC;
    --m-teal:    #A0E7E5;
    --m-orange:  #FFB347;
    --m-purple:  #C9B1FF;
    --m-lime:    #B5EAD7;
    --m-dark:    #3D3D3D;
    --m-surface: #FFFDF7;
    --m-surface2:#FFF0F5;
}

[data-scheme="3"] {
    --m-yellow:  #FFD166;
    --m-pink:    #EF476F;
    --m-teal:    #06D6A0;
    --m-orange:  #F77F00;
    --m-purple:  #7B2D8B;
    --m-lime:    #80ED99;
    --m-dark:    #073B4C;
    --m-surface: #E8F4F8;
    --m-surface2:#D0EAF0;
}

[data-scheme="4"] {
    --m-yellow:  #FFCF00;
    --m-pink:    #FF4040;
    --m-teal:    #FF8C00;
    --m-orange:  #FF5500;
    --m-purple:  #CC2200;
    --m-lime:    #FFE566;
    --m-dark:    #1C0A00;
    --m-surface: #FFF8F0;
    --m-surface2:#FFE8D0;
}

[data-scheme="5"] {
    --m-yellow:  #D4FF00;
    --m-pink:    #FF61A6;
    --m-teal:    #00C896;
    --m-orange:  #FF9500;
    --m-purple:  #5C4033;
    --m-lime:    #7FFF00;
    --m-dark:    #1A2E1A;
    --m-surface: #F0FAF0;
    --m-surface2:#E0F0E0;
}

[data-scheme="6"] {
    --m-yellow:  #FFE066;
    --m-pink:    #FF6EC7;
    --m-teal:    #4FC3F7;
    --m-orange:  #FF8A65;
    --m-purple:  #7986CB;
    --m-lime:    #AED581;
    --m-dark:    #1A237E;
    --m-surface: #F8FBFF;
    --m-surface2:#E8F0FE;
}

[data-scheme="7"] {
    --m-yellow:  #FFB700;
    --m-pink:    #FF6B6B;
    --m-teal:    #C77DFF;
    --m-orange:  #FF9F1C;
    --m-purple:  #7B2FBE;
    --m-lime:    #FFD460;
    --m-dark:    #2D1B00;
    --m-surface: #FFF9F0;
    --m-surface2:#FFEEDD;
}

[data-scheme="8"] {
    --m-yellow:  #FFFFFF;
    --m-pink:    #BBBBBB;
    --m-teal:    #888888;
    --m-orange:  #CCCCCC;
    --m-purple:  #555555;
    --m-lime:    #EEEEEE;
    --m-dark:    #000000;
    --m-surface: #F5F5F5;
    --m-surface2:#E8E8E8;
}

[data-scheme="9"] {
    --m-yellow:  #FFE600;
    --m-pink:    #FF2079;
    --m-teal:    #00F5FF;
    --m-orange:  #FF6B00;
    --m-purple:  #BD00FF;
    --m-lime:    #39FF14;
    --m-dark:    #0D0221;
    --m-surface: #0D0221;
    --m-surface2:#160535;
    --m-shadow:  rgba(0,0,0,0.5);
}

.chat-panel.requests-mode .chat-input {
    display: none !important;
}

/* ========== ФИКС ВЫСОТЫ ШАПОК ========== */
.header,
.chat-header {
    padding: 0 20px !important;
    height: 60px !important;
    min-height: unset !important;
    box-sizing: border-box !important;
}

.header .logout-btn,
.chat-header button:not(.msg-delete-btn) {
    margin: 0 !important;
    padding: 5px 14px !important;
    height: auto !important;
}

@media (max-width: 768px) {
    .header,
    .chat-header {
        height: 56px !important;
        padding: 0 16px !important;
    }
}

/* ========== MESSAGE DELETE BUTTON ========== */
.message {
    position: relative;
}

.msg-delete-btn {
    display: none;
    position: absolute;
    top: -8px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 2px solid var(--m-dark);
    border-radius: 50%;
    background: var(--m-surface);
    color: var(--m-dark);
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    box-shadow: 2px 2px 0 var(--m-dark);
}

.message.own  .msg-delete-btn { right: -8px; }
.message.other .msg-delete-btn { left: -8px; }

.message.pending .msg-delete-btn {
    display: none !important;
}

@media (hover: hover) {
    .message:hover .msg-delete-btn {
        display: flex;
    }
    .msg-delete-btn:hover {
        background: var(--m-pink);
        color: #fff;
        border-color: var(--m-pink);
    }
}

/* ========== DELETE CONFIRMATION DIALOG ========== */
.msg-delete-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-delete-dialog {
    background: var(--m-surface);
    border: 4px solid var(--m-dark);
    border-radius: 20px;
    padding: 28px 24px 20px;
    min-width: 260px;
    max-width: 350px;
    width: 90%;
    box-shadow: 8px 8px 0 var(--m-dark);
    text-align: center;
    animation: ctx-pop .14s ease-out;
}

.msg-delete-title {
    font-size: 14px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--m-dark);
    margin-bottom: 20px;
}

.msg-delete-btns {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-delete-opt {
    width: 100%;
    padding: 12px;
    border: 3px solid var(--m-dark);
    border-radius: 50px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
    transition: background .15s, transform .1s;
    box-shadow: 3px 3px 0 var(--m-dark);
}

.msg-delete-me {
    background: var(--m-yellow);
    color: var(--m-dark);
}
.msg-delete-me:hover { background: var(--m-teal); color: #fff; }

.msg-delete-both {
    background: var(--m-pink);
    color: #fff;
}
.msg-delete-both:hover { background: #c0392b; }

.msg-delete-cancel {
    background: transparent;
    border-color: #bbb;
    color: #999;
    font-size: 11px;
    box-shadow: none;
}
.msg-delete-cancel:hover { background: var(--m-surface2); color: var(--m-dark); }

.msg-delete-opt:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--m-dark); }

/* ========== MESSAGE CONTEXT MENU ========== */
.msg-ctx-menu {
    position: fixed;
    z-index: 9999;
    background: var(--m-surface);
    border: 3px solid var(--m-dark);
    border-radius: 16px;
    box-shadow: 6px 6px 0 var(--m-dark);
    overflow: hidden;
    min-width: 210px;
    animation: ctx-pop .12s ease-out;
    transform-origin: top left;
    -webkit-user-select: none;
    user-select: none;
}

@keyframes ctx-pop {
    from { opacity: 0; transform: scale(.88); }
    to   { opacity: 1; transform: scale(1); }
}

.msg-ctx-item {
    display: block;
    width: 100%;
    padding: 13px 18px;
    border: none;
    border-bottom: 2px solid var(--m-dark);
    background: transparent;
    color: var(--m-dark);
    font-family: inherit;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    text-align: left;
    cursor: pointer;
    transition: background .1s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

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

.msg-ctx-item:hover,
.msg-ctx-item:active {
    background: var(--m-surface2);
}

.msg-ctx-danger {
    color: #c0392b;
}

.msg-ctx-danger:hover,
.msg-ctx-danger:active {
    background: #fff0f0;
}

.msg-ctx-cancel {
    color: #999;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    font-size: 12px;
}

.msg-ctx-cancel:hover,
.msg-ctx-cancel:active {
    background: var(--m-surface2);
}

@media (max-width: 768px) {
    .msg-ctx-menu {
        min-width: 230px;
        border-radius: 18px;
    }

    .msg-ctx-item {
        padding: 16px 20px;
        font-size: 14px;
    }
}

/* ========== iOS FIXES ========== */
.chat-messages .message img,
.chat-messages .message video,
.chat-messages .message a {
    -webkit-touch-callout: none;
    pointer-events: none;
}

.chat-messages .message .msg-file-card {
    pointer-events: auto;
    -webkit-touch-callout: none;
}

.chat-messages .message img {
    pointer-events: auto;
}

/* ========== CITIES GAME ========== */
.cities-msg {
    max-width: 78%;
    margin: 6px 12px;
    padding: 10px 14px;
    border: 3px solid var(--m-dark);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
    overflow: visible;
    box-sizing: border-box;
}

.cities-msg--bot {
    background: var(--m-teal);
    color: var(--m-dark);
    align-self: flex-start;
    border-radius: 4px 18px 18px 4px;
    box-shadow: none;
    margin-left: 12px;
}

.cities-msg--user {
    background: var(--m-yellow);
    color: var(--m-dark);
    align-self: flex-end;
    border-radius: 18px 4px 4px 18px;
    box-shadow: none;
    margin-left: auto;
    margin-right: 12px;
}

#chatMessages:has(.cities-msg) {
    display: flex;
    flex-direction: column;
    padding: 12px 0;
}

.cities-msg:has(.cities-msg__img-wrap) {
    padding-bottom: 0;
}

.cities-msg__img-wrap {
    margin-top: 8px;
    margin-left: -14px;
    margin-right: -14px;
    margin-bottom: 0;
    line-height: 0;
    overflow: hidden;
    border-radius: 0 0 15px 15px;
}

.cities-msg__img {
    width: calc(100% + 28px);
    height: auto;
    display: block;
}

.cities-msg--entering {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
}

.cities-msg {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.cities-msg:not(.cities-msg--entering) {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ========== ПЕРЕНОСЫ СТРОК И ОБЫЧНЫЙ ТЕКСТ В СООБЩЕНИЯХ ========== */
.message .msg-text,
.message > div:not(.msg-image-wrap):not(.msg-video-wrap):not(.msg-file-card) {
    white-space: pre-wrap; 
    word-break: break-word;
    font-weight: 400;
    font-family: inherit;
}

/* Время, имена, заголовки остаются жирными */
.message-time,
.contact-name,
.contact-last-msg,
.chat-header,
.header span {
    font-weight: 900;
}

/* ========== HTML-ФОРМАТИРОВАНИЕ В СООБЩЕНИЯХ ========== */
.msg-text b, .msg-text strong { font-weight: 700; }
.msg-text i, .msg-text em     { font-style: italic; }
.msg-text u                   { text-decoration: underline; }
.msg-text s, .msg-text strike { text-decoration: line-through; }
.msg-text code {
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 13px;
    background: rgba(0,0,0,0.08);
    padding: 1px 5px;
    border-radius: 4px;
}
.msg-text a {
    color: inherit;
    text-decoration: underline;
    opacity: 0.8;
}
.msg-text a:hover { opacity: 1; }
/* ===== WEATHER FORECAST ===== */
.weather-forecast {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    margin: 0;
}
.forecast-day {
    display: grid;
    grid-template-columns: 56px 28px 1fr auto;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.10);
    border-radius: 14px;
    padding: 10px 14px;
    font-weight: 700;
}
.forecast-label {
    font-size: 12px;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.forecast-icon  { font-size: 22px; line-height: 1; text-align: center; }
.forecast-desc  { font-size: 12px; opacity: 0.6; text-transform: capitalize; }
.forecast-temps { font-size: 13px; display: flex; gap: 8px; justify-content: flex-end; white-space: nowrap; }
.forecast-max   { color: #ff6b35; }
.forecast-min   { opacity: 0.55; }
.forecast-precip { font-size: 10px; opacity: 0.65; grid-column: 3 / 5; margin-top: -4px; }
/* ===== NEWS SOURCE ===== */
.news-item__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.news-item__meta small {
    display: inline;
    margin-top: 0;
}

.news-item__source {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 800;
    color: var(--m-teal, #00C2C7);
    background: color-mix(in srgb, var(--m-teal, #00C2C7) 12%, transparent);
    border: 1.5px solid color-mix(in srgb, var(--m-teal, #00C2C7) 35%, transparent);
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== NEWS SOURCE override: plain text ===== */
.news-item__source {
    display: inline;
    background: none;
    border: none;
    padding: 0;
    border-radius: 0;
    font-size: 11px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: normal;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
}
/* ========== CRYPTO MODULE ========== */
.crypto-wrap {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: 100%;
    box-sizing: border-box;
}

.crypto-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.crypto-stat {
    background: var(--m-dark, #1A1A1A);
    border: 2.5px solid var(--m-dark, #1A1A1A);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.crypto-stat-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    opacity: .5;
    color: #fff;
}

.crypto-stat-val {
    font-size: 15px;
    font-weight: 800;
    font-family: 'Inter Tight', 'Arial Black', sans-serif;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btc-canvas {
    width: 100%;
    height: 260px;
    border-radius: 12px;
    display: block;
    cursor: crosshair;
    flex-shrink: 0;
}

.crypto-tooltip {
    position: absolute;
    background: rgba(26,26,26,0.95);
    border: 1.5px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    color: #fff;
    pointer-events: none;
    z-index: 10;
    line-height: 1.5;
    white-space: nowrap;
}

.crypto-tooltip b {
    font-size: 14px;
    color: #00C2C7;
}

.crypto-tooltip span {
    opacity: .6;
}

.crypto-loading,
.crypto-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    font-size: 15px;
    font-weight: 600;
    opacity: .7;
}

/* .chat-messages needs position:relative for tooltip absolute positioning */
.crypto-mode .chat-messages {
    position: relative;
    overflow-y: auto;
}

.chat-panel.crypto-mode .chat-input {
    display: none !important;
}
/* ===== WEATHER TEMP CHART ===== */
.weather-temp-chart-wrap {
    margin: 0;
    background: var(--m-surface);
    border: 4px solid var(--m-dark);
    border-radius: 24px;
    overflow: hidden;
}

.weather-temp-chart {
    width: 100%;
    height: 160px;
    display: block;
    border-radius: 0;
}