.messages-page-v1 {
    width: min(860px, 100%);
    height: 100dvh;
    margin: 0 auto;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    background: #f6f7fb;
    border-left: 1px solid #e5e7f0;
    border-right: 1px solid #e5e7f0;
}

.messages-header-v1 {
    min-height: 72px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border-bottom: 1px solid #e5e7f0;
    position: sticky;
    top: 0;
    z-index: 5;
}

.messages-header-v1 > div {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.messages-header-v1 strong {
    color: #171a2b;
    font-size: 17px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.messages-header-v1 small {
    color: #6d7284;
    font-size: 12px;
}

.messages-back-v1 {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: #f0f1f7;
    color: #171a2b;
    text-decoration: none;
    font-size: 22px;
    font-weight: 900;
}

.messages-alert-v1 {
    margin: 10px 16px 0;
    padding: 11px 13px;
    border: 1px solid #f1b9b4;
    border-radius: 12px;
    background: #fff0ef;
    color: #a72c22;
    font-size: 13px;
    font-weight: 700;
}

.messages-thread-v1 {
    min-height: 0;
    padding: 18px 16px 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.messages-empty-v1 {
    min-height: 100%;
    display: grid;
    place-content: center;
    justify-items: center;
    text-align: center;
    color: #6d7284;
}

.messages-empty-v1 > span {
    margin-bottom: 10px;
    font-size: 42px;
    color: #5b5fef;
}

.messages-empty-v1 strong {
    color: #171a2b;
    font-size: 20px;
}

.messages-empty-v1 p {
    max-width: 340px;
    margin: 6px 0 0;
    line-height: 1.5;
}

.message-row-v1 {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.message-row-v1.own {
    justify-content: flex-end;
}

.message-bubble-v1 {
    width: fit-content;
    max-width: min(76%, 610px);
    padding: 10px 14px 8px;
    display: grid;
    gap: 4px;
    border: 1px solid #e5e7f0;
    border-radius: 18px 18px 18px 5px;
    background: #fff;
    color: #171a2b;
    box-shadow: 0 4px 18px rgba(22, 26, 43, .035);
}

.message-row-v1.own .message-bubble-v1 {
    border-color: #5b5fef;
    border-radius: 18px 18px 5px 18px;
    background: #5b5fef;
    color: #fff;
}

.message-sender-v1 {
    color: #5b5fef;
    font-size: 11px;
    font-weight: 900;
}

.message-text-v1 {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.42;
    font-size: 15px;
}

.message-bubble-v1 small {
    justify-self: end;
    color: #6d7284;
    font-size: 10px;
}

.message-row-v1.own .message-bubble-v1 small {
    color: rgba(255, 255, 255, .72);
}

.message-system-v1 {
    width: fit-content;
    max-width: 84%;
    margin: 10px auto;
    padding: 7px 12px;
    border-radius: 999px;
    background: #eceef5;
    color: #6d7284;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

.messages-composer-v1 {
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr 48px;
    gap: 9px;
    align-items: end;
    border-top: 1px solid #e5e7f0;
    background: #fff;
}

.messages-composer-v1 textarea {
    width: 100%;
    min-height: 48px;
    max-height: 140px;
    padding: 13px 15px;
    resize: vertical;
    border: 1px solid #dfe2eb;
    border-radius: 16px;
    outline: none;
    background: #f8f9fc;
    color: #171a2b;
    font: inherit;
    line-height: 1.35;
}

.messages-composer-v1 textarea:focus {
    border-color: #5b5fef;
    background: #fff;
}

.messages-composer-v1 button {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 15px;
    background: #5b5fef;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    font-weight: 900;
}

.messages-readonly-v1 {
    padding: 15px 18px max(15px, env(safe-area-inset-bottom));
    border-top: 1px solid #e5e7f0;
    background: #fff;
    color: #6d7284;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
}

@media (max-width: 720px) {
    .messages-page-v1 {
        border: 0;
    }

    .message-bubble-v1 {
        max-width: 84%;
    }
}
