.page {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 3rem 1.25rem 11rem;
}

/* intro */

.intro {
    margin-bottom: 2.5rem;
}

.intro h1 {
    margin: 0 0 1rem;
    font-family: var(--font-title);
    font-size: clamp(1.75rem, 4vw, 2.4rem);
    font-weight: 600;
    line-height: 1.2;
    color: var(--primary);
}

.intro p {
    margin: 0 0 0.75rem;
}

.intro .disclaimer {
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    background: var(--warning-background);
    font-size: 0.925rem;
    color: var(--text);
}

/* conversation */

.conversation {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    border-radius: 18px;
    padding: 0.75rem 1.1rem;
    overflow-wrap: anywhere;
}

.question {
    align-self: flex-end;
    max-width: 75%;
    border-bottom-right-radius: 4px;
    background: var(--question-background);
    color: var(--question-text);
    white-space: pre-wrap;
}

.answer {
    align-self: flex-start;
    width: 100%;
    max-width: 92%;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 1rem 1.35rem;
    scroll-margin-top: 1.5rem;
}

/* rendered Markdown inside an answer */

.answer-content > :first-child {
    margin-top: 0;
}

.answer-content > :last-child {
    margin-bottom: 0;
}

.answer-content p {
    margin: 0 0 0.85rem;
}

.answer-content ul,
.answer-content ol {
    margin: 0 0 0.85rem;
    padding-left: 1.4rem;
}

.answer-content li {
    margin-bottom: 0.35rem;
}

.answer-content li::marker {
    color: var(--primary);
}

.answer-content strong {
    color: var(--primary);
    font-weight: 600;
}

.answer-content h1,
.answer-content h2,
.answer-content h3 {
    margin: 1.25rem 0 0.5rem;
    font-size: 1.05rem;
    color: var(--primary);
}

/* sources */

.sources {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.sources-label {
    margin-right: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.source {
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: var(--primary-soft);
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--primary);
    transition: background-color 0.15s;
}

.source:hover {
    background: var(--border);
}

/* loading and error */

.typing {
    width: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.925rem;
    color: var(--text-muted);
}

.typing-dots {
    display: inline-flex;
    gap: 0.25rem;
}

.typing-dots span {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--primary);
    animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-0.25rem);
    }
}

.error {
    border-color: var(--error);
    color: var(--error);
}

/* message input, fixed at the bottom */

.composer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 0.75rem 1.25rem 0.5rem;
    background: linear-gradient(to bottom, transparent, var(--background) 30%);
}

.composer-inner {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.composer-inner:focus-within {
    border-color: var(--primary);
}

.composer-input {
    flex: 1;
    min-height: 2.5rem;
    max-height: 10rem;
    padding: 0.45rem 0;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    font: inherit;
    color: var(--text);
    field-sizing: content;
}

.composer-input::placeholder {
    color: var(--text-muted);
}

.composer-send {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: var(--surface);
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
}

.composer-send:hover:not(:disabled) {
    background: var(--primary-hover);
}

.composer-send:disabled {
    opacity: 0.4;
    cursor: default;
}

.composer-send svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: currentColor;
}

.composer-hint {
    max-width: var(--content-width);
    margin: 0.35rem auto 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* phones */

@media (max-width: 600px) {
    .page {
        padding: 1.75rem 1rem 10rem;
    }

    .question,
    .answer {
        max-width: 100%;
    }

    .answer {
        padding: 0.9rem 1rem;
    }

    .composer {
        padding: 0.5rem 0.75rem 0.5rem;
    }

    .composer-hint {
        display: none;
    }
}
