.chat-ui.telegram {
    --chat-bg: #0b0b0d;
    --header-bg: rgba(15, 15, 18, 0.82);
    --accent: #3a8df0;
    --status-seen: #ffffff;

    font-family: -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
}

/* ----- Header: back+count pill (left), centered name, avatar (right) ----- */
.chat-ui.telegram .chat-header {
    position: relative;
    height: 56px;
    padding: 6px 10px;
    background: var(--header-bg);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-ui.telegram .chat-header-main {
    flex: 1;
    gap: 0;
}

.chat-ui.telegram .chat-back-arrow {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    height: 28px;
    padding: 0 10px 0 4px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.chat-ui.telegram .wa-back-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #ffffff;
}

.chat-ui.telegram .chat-unread {
    position: static;
    min-width: auto;
    height: auto;
    padding: 0;
    background: transparent;
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 500;
}

/* Name + subtitle centered across the whole header. */
.chat-ui.telegram .min-w-0 {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: max-content;
    max-width: 58%;
    text-align: center;
    pointer-events: none;
}

.chat-ui.telegram .chat-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: #ffffff;
}

.chat-ui.telegram .chat-subtitle {
    margin-top: 1px;
    font-size: 0.66rem;
    color: #8d9499;
}

.chat-ui.telegram .chat-avatar {
    order: 3;
    margin-left: auto;
    width: 2.15rem;
    height: 2.15rem;
    background: linear-gradient(135deg, #72a6f0, #9b8cf0);
    font-size: 0.66rem;
}

.chat-ui.telegram .chat-header-actions {
    display: none;
}

/* ----- Body: doodle wallpaper ----- */
.chat-ui.telegram .chat-body {
    background-color: #0b0b0d;
    background-image: url('/images/chat/telegram-bg.jpg');
    background-size: 420px auto;
    background-position: top center;
    background-repeat: repeat;
}

.chat-ui.telegram .chat-messages {
    padding: 0.6rem 0.55rem 5rem;
}

/* ----- Bubbles ----- */
.chat-ui.telegram .bubble-row {
    margin-bottom: 0.3rem;
}

.chat-ui.telegram .bubble-row-grouped {
    margin-bottom: 0.1rem;
}

.chat-ui.telegram .bubble {
    max-width: 78%;
    padding: 0.34rem 0.56rem 0.32rem;
    box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 16px;
}

.chat-ui.telegram .bubble.sent {
    background: linear-gradient(160deg, #4f8cf2 0%, #9168ec 100%);
    border-bottom-right-radius: 6px;
}

.chat-ui.telegram .bubble.received {
    background: rgba(28, 28, 33, 0.92);
    border: none;
    border-bottom-left-radius: 6px;
}

/* Keep full rounding between grouped same-sender bubbles. */
.chat-ui.telegram .bubble-row-sent:has(+ .bubble-row-sent) .bubble.sent {
    border-bottom-right-radius: 16px;
}

.chat-ui.telegram .bubble-row-received:has(+ .bubble-row-received) .bubble.received {
    border-bottom-left-radius: 16px;
}

.chat-ui.telegram .bubble-content {
    font-size: 0.9rem;
    line-height: 1.3;
    color: #ffffff;
}

/* Time (and ticks for outgoing) sit at the bottom-right inside the bubble. */
.chat-ui.telegram .bubble-meta {
    margin-top: 1px;
    justify-content: flex-end;
    gap: 3px;
}

.chat-ui.telegram .bubble-time {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.6);
}

.chat-ui.telegram .bubble.received .bubble-time {
    color: rgba(255, 255, 255, 0.45);
}

.chat-ui.telegram .bubble-status {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.85);
}

.chat-ui.telegram .bubble-status.status-seen {
    color: #ffffff;
}

.chat-ui.telegram .bubble-sender {
    color: #7cc0f0;
}

/* ----- Date / service pill ----- */
.chat-ui.telegram .system-note {
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    border-radius: 9999px;
    font-size: 0.68rem;
    padding: 0.25rem 0.72rem;
}

/* ----- Footer: paperclip + "Message" pill + mic ----- */
.chat-ui.telegram .chat-footer {
    padding: 6px 8px 9px;
    background: rgba(15, 15, 18, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
    gap: 0;
}

.chat-ui.telegram .tg-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.chat-ui.telegram .tg-attach,
.chat-ui.telegram .tg-mic {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: #8d9499;
    cursor: pointer;
}

.chat-ui.telegram .tg-attach svg,
.chat-ui.telegram .tg-mic svg {
    width: 22px;
    height: 22px;
}

.chat-ui.telegram .tg-field {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    min-height: 34px;
    padding: 0 34px 0 14px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 9999px;
}

.chat-ui.telegram .tg-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 0.92rem;
    padding: 7px 0;
}

.chat-ui.telegram .tg-input::placeholder,
.chat-ui.telegram .tg-input.composer-empty {
    color: #8d9499;
}

.chat-ui.telegram .tg-sticker {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: #8d9499;
    cursor: pointer;
}

.chat-ui.telegram .tg-sticker svg {
    width: 20px;
    height: 20px;
}
