html, body {
    height: 100%;
    margin: 0;
    font-family: "Segoe UI", "Roboto", "Arial", sans-serif;
    background: #222c37;
}
body, #main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}
.container {
    background: #273445;
    border-radius: 16px;
    box-shadow: 0 4px 24px #0003;
    padding: 40px 30px 30px 30px;
    min-width: 320px;
    max-width: 400px;
    width: 90vw;
    margin-top: 12vh;
}
.logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    margin: 0 auto 16px auto;
    display: block;
}
h1 {
    color: #fff;
    font-weight: 600;
    font-size: 2em;
    margin-bottom: 16px;
    text-align: center;
}
label {
    color: #b3c4d1;
    font-size: 1em;
    margin-bottom: 8px;
    display: block;
}
input, button {
    font-size: 1em;
}
input[type="text"], input[type="password"], input[type="number"] {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #375472;
    background: #212d3b;
    color: #e5ecf4;
    margin-bottom: 14px;
    outline: none;
    box-sizing: border-box;
    transition: border 0.2s;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus {
    border-color: #399be5;
}
button {
    background: #399be5;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 0;
    width: 100%;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
button:hover, button:focus {
    background: #2088db;
}
#result, #nickresult {
    margin-top: 18px;
    color: #fff;
    font-weight: 600;
    text-align: center;
    font-size: 1.13em;
}

/* --- Telegram чат окно --- */
.tg-app {
    display: flex;
    width: 92vw;
    max-width: 1050px;
    min-height: 500px;
    height: 72vh;
    border-radius: 22px;
    overflow: hidden;
    background: #222c37;
    box-shadow: 0 4px 28px #0004;
    margin-top: 8vh;
}
.tg-chats {
    width: 330px;
    min-width: 170px;
    background: #222d3a;
    border-right: 1px solid #313c4a;
    display: flex;
    flex-direction: column;
}
.tg-chats-head {
    padding: 18px 16px;
    color: #fff;
    font-size: 1.1em;
    font-weight: 600;
    border-bottom: 1px solid #313c4a;
    background: #233152;
}
.tg-chat-list {
    flex: 1;
    overflow-y: auto;
}
.tg-chat-item {
    padding: 15px 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.14s;
    border-bottom: 1px solid #232b38;
}
.tg-chat-item:hover, .tg-chat-item.active {
    background: #2a3951;
}
.tg-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    margin-right: 13px;
    background: #399be5;
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15em;
}
.tg-chat-title {
    font-weight: 600;
    color: #fff;
}
.tg-chat-lastmsg {
    color: #b1b7c7;
    font-size: 0.97em;
}
.tg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #242f3e;
    min-width: 0;
}
.tg-main-head {
    padding: 18px 24px;
    border-bottom: 1px solid #313c4a;
    color: #fff;
    font-weight: 600;
    background: #233152;
}
.tg-main-chat {
    flex: 1;
    padding: 18px 18px 0 18px;
    color: #c8d1e0;
    font-size: 1.08em;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tg-main-footer {
    padding: 12px 16px;
    border-top: 1px solid #313c4a;
    background: #233152;
    display: flex;
}
.tg-main-footer input {
    flex: 1;
    padding: 11px;
    height: 42px;        
    border-radius: 8px;
    border: 1px solid #375472;
    background: #212d3b;
    color: #e5ecf4;
    margin-right: 10px;
    font-size: 1em;
    outline: none;
    transition: border 0.2s;
}
.tg-main-footer button {
    padding: 0 24px;     /* по бокам! */
    font-size: 1em;
    height: 42px;        /* как у input */
    border-radius: 8px;
    background: #399be5;
    color: #fff;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 85px;
    width: auto;
    box-sizing: border-box;
    margin: 0;
    display: inline-block;
}
.tg-main-footer button:hover {
    background: #2088db;
}

@media (max-width: 900px) {
    .tg-app {flex-direction: column; min-width: unset; width: 100vw; height: 92vh;}
    .tg-chats {width: 100vw; min-width: unset;}
}

/* --- Telegram message bubbles --- */
.tg-msg {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.tg-msg.mine {
    justify-content: flex-end;
}

.tg-msg-bubble {
    max-width: 75vw;
    min-width: 32px;
    background: #313d51;
    color: #fff;
    padding: 12px 18px 10px 18px;
    border-radius: 22px;
    border-bottom-right-radius: 8px;
    border-bottom-left-radius: 22px;
    box-shadow: 0 2px 10px #0002;
    position: relative;
    font-size: 1.05em;
    word-break: break-word;
    white-space: pre-wrap;
    display: flex;
    flex-direction: column;
}

.tg-msg.mine .tg-msg-bubble {
    background: #399be5;
    color: #fff;
    border-radius: 22px;
    border-bottom-right-radius: 22px;
    border-bottom-left-radius: 8px;
}

.tg-msg-text {
    margin-bottom: 2px;
}

.tg-msg-time {
    align-self: flex-end;
    font-size: 0.77em;
    color: #c1d2eea6;
    margin-top: 5px;
    margin-right: 2px;
}

.tg-msg-bubble img {
    max-width: 270px;
    max-height: 270px;
    border-radius: 13px;
    margin-bottom: 6px;
    box-shadow: 0 2px 10px #0002;
    display: block;
}
.tg-hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 2em;
    margin-right: 14px;
    cursor: pointer;
    outline: none;
}

/* На мобиле гамбургер и скрывающийся список чатов */
@media (max-width: 700px) {
    .tg-chats {
        position: fixed;
        top: 0;
        left: -100vw;
        width: 85vw;
        max-width: 340px;
        height: 100vh;
        z-index: 25;
        background: #222d3a;
        transition: left 0.24s;
        box-shadow: 2px 0 24px #0003;
        display: flex;
        flex-direction: column;
    }
    .tg-chats.open {
        left: 0;
    }
    .tg-hamburger {
        display: inline-block;
    }
    .tg-app {
        min-width: unset;
        flex-direction: column;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        margin-top: 0;
    }
    .tg-main {
        min-width: 0;
        width: 100vw;
    }
    .tg-main-head {
        display: flex;
        align-items: center;
        padding-left: 7px;
    }
}
