.thread {
    display: flex;
    flex-direction: column;
    gap: 28px;
    width: min(820px, 100%);
    margin: 0 auto;
}

.thread:not(:empty) {
    padding: 24px 0 32px;
}

.message {
    animation: rise .35s var(--ease) both;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.message.user {
    align-self: flex-end;
    max-width: 80%;
    padding: 14px 20px;
    border-radius: 24px 24px 6px 24px;
    background: var(--navy);
    color: #fff;
    font-size: 17px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message.user .files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.message.user .files span {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    font-size: 13px;
}

.message.user .files img {
    max-height: 120px;
    border-radius: 12px;
}

.message.bot {
    font-size: 18px;
    line-height: 1.65;
}

.message.bot > :first-child {
    margin-top: 0;
}

.message.bot > :last-child {
    margin-bottom: 0;
}

.message.bot h1,
.message.bot h2,
.message.bot h3 {
    font-family: var(--serif);
    font-weight: 500;
    line-height: 1.2;
    margin: 1.4em 0 .5em;
}

.message.bot h1 { font-size: 32px; }
.message.bot h2 { font-size: 27px; }
.message.bot h3 { font-size: 22px; }

.message.bot a {
    color: #1351b4;
    text-underline-offset: 3px;
}

.message.bot code {
    padding: 2px 6px;
    border-radius: 6px;
    background: #e8edf3;
    font-size: .9em;
}

.message.bot pre {
    overflow-x: auto;
    padding: 16px;
    border-radius: 14px;
    background: #e8edf3;
}

.message.bot pre code {
    padding: 0;
    background: none;
}

.message.bot table {
    border-collapse: collapse;
    width: 100%;
    font-size: 16px;
}

.message.bot th,
.message.bot td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.message.bot blockquote {
    margin: 1em 0;
    padding-left: 16px;
    border-left: 3px solid var(--green);
    color: var(--muted);
}

.message.error {
    padding: 14px 18px;
    border-radius: 16px;
    background: #fdecec;
    color: #8a1c1c;
    font-size: 16px;
}

.typing {
    display: inline-flex;
    gap: 6px;
    padding: 6px 0;
}

.typing i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--navy);
    opacity: .3;
    animation: blink 1.2s infinite;
}

.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

@keyframes blink {
    30% {
        opacity: 1;
    }
}

@media (max-width: 640px) {
    .message.user {
        max-width: 90%;
        font-size: 16px;
    }

    .message.bot {
        font-size: 16px;
    }
}
