:root {
    --tg-blue: #0088cc;
    --tg-bg: #e7ebf0;
    --tg-sent: #effdde;
    --tg-received: #ffffff;
    --text-dark: #222222;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

body { background: var(--tg-bg); display: flex; justify-content: center; height: 100vh; }

.tg-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    background: white;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header */
.header {
    background: var(--tg-blue);
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-info h2 { font-size: 16px; font-weight: 600; }
.header-info p { font-size: 12px; opacity: 0.8; }

/* Chat Area */
.chat-area {
    flex: 1;
    background: #cad3d8;
    background-image: url('https://www.transparenttextures.com/patterns/pinstriped-suit.png');
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg-content { display: flex; align-items: flex-end; gap: 10px; }
.msg-bubble { 
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
}

.msg.received .msg-bubble { background: var(--tg-received); border-bottom-left-radius: 4px; }
.msg.sent .msg-bubble { background: var(--tg-sent); border-bottom-right-radius: 4px; }

.chat-ava, .chat-ava-emoji {
    width: 35px; height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eee;
    font-size: 18px;
    overflow: hidden;
    object-fit: cover;
    flex-shrink: 0;
}

.msg.sent { align-self: flex-end; }
.msg.received { align-self: flex-start; }

.msg-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

/* Input */
.input-area {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
}

input {
    flex: 1;
    border: none;
    padding: 10px;
    outline: none;
    font-size: 15px;
}

.send-btn {
    color: var(--tg-blue);
    font-size: 24px;
    cursor: pointer;
}

/* Sidebar Menu */
.menu-btn { cursor: pointer; font-size: 18px; }

.overlay {
    position: fixed;
    top: 0; left: -100%;
    width: 80%; max-width: 300px; height: 100%;
    background: white;
    z-index: 100;
    transition: 0.3s;
    box-shadow: 5px 0 15px rgba(0,0,0,0.1);
}

.overlay.active { left: 0; }

.overlay-header {
    background: var(--tg-blue);
    color: white;
    padding: 30px 20px;
}

.contact-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}
.contact-item:hover { background: #f9f9f9; }

/* --- MODALS --- */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal-content {
    background: white;
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
}
.input-group {
    margin-bottom: 15px;
    text-align: left;
}
.input-group label {
    display: block;
    font-size: 13px;
    color: #888;
    margin-bottom: 5px;
}
.input-group input, .input-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
}
.input-group textarea {
    height: 80px;
    resize: none;
}
.btn {
    width: 100%;
    padding: 12px;
    background: var(--tg-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}
.btn-link {
    width: 100%;
    padding: 10px;
    background: none;
    color: #888;
    border: none;
    cursor: pointer;
    margin-top: 5px;
}
.profile-view {
    text-align: center;
}
#profileAvaLarge {
    font-size: 80px;
    margin-bottom: 15px;
    background: #f0f4f8;
    width: 120px;
    height: 120px;
    line-height: 120px;
    border-radius: 50%;
    margin: 0 auto 15px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#profileAvaLarge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.chat-ava, .chat-ava-emoji {
    cursor: pointer;
    transition: transform 0.2s;
}
.chat-ava:hover, .chat-ava-emoji:hover {
    transform: scale(1.1);
}
.menu-item {
    padding: 15px 20px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}
.menu-item:hover {
    background: #f5f5f5;
}
.menu-item i {
    margin-right: 15px;
    width: 20px;
    color: #666;
}

.markdown-body p { margin-bottom: 8px; }
.markdown-body ul, .markdown-body ol { margin-left: 20px; margin-bottom: 8px; }
.markdown-body code { background: rgba(0,0,0,0.1); padding: 2px 4px; border-radius: 4px; font-family: monospace; }
.markdown-body pre { background: #282c34; color: #abb2bf; padding: 10px; border-radius: 8px; overflow-x: auto; margin-bottom: 8px; }
.markdown-body pre code { background: none; color: inherit; padding: 0; }
.markdown-body table { border-collapse: collapse; width: 100%; margin-bottom: 8px; }
.markdown-body th, .markdown-body td { border: 1px solid #ddd; padding: 6px; text-align: left; }

