.chat-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}
.message {
    display: flex;
}
.message.user {
    justify-content: flex-end;
}
.bubble {
    margin: 0;
    max-width: 88%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: 0.625rem 0.875rem;
    border-radius: 16px 16px 16px 4px;
    background: var(--bg-muted);
}

/* The agent's reply is markdown, shown as formatted text */
.message.agent .bubble {
    white-space: normal;
}
.message.agent .bubble > :first-child {
    margin-top: 0;
}
.message.agent .bubble > :last-child {
    margin-bottom: 0;
}
.message.agent .bubble p {
    margin: 0 0 0.625rem;
}
.message.agent .bubble h1,
.message.agent .bubble h2,
.message.agent .bubble h3,
.message.agent .bubble h4 {
    margin: 0.875rem 0 0.375rem;
    font-size: 1rem;
    line-height: 1.3;
}
.message.agent .bubble ul,
.message.agent .bubble ol {
    margin: 0 0 0.625rem;
    padding-left: 1.25rem;
}
.message.agent .bubble ul {
    list-style: disc;
}
.message.agent .bubble ol {
    list-style: decimal;
}
.message.agent .bubble li + li {
    margin-top: 0.25rem;
}
.message.agent .bubble code {
    padding: 0.0625rem 0.25rem;
    border-radius: 4px;
    background: var(--border);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}
.message.agent .bubble pre {
    overflow-x: auto;
}
.message.user .bubble {
    border-radius: 16px 16px 4px 16px;
    background: var(--navy);
    color: #ffffff;
}
.message.error .bubble {
    background: #fdecea;
    color: var(--red);
}

.step-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}
.step {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.dot {
    width: 0.5rem;
    height: 0.5rem;
    margin-top: 0.3rem; /* in line with the first line of the label */
    border-radius: 50%;
    background: var(--border-strong);
}
.step-text {
    display: flex;
    flex-direction: column;
}
.step-info {
    font-size: 0.6875rem;
    color: var(--text-soft);
}
.step.running .dot {
    background: #e0a818;
}
.step.done .dot {
    background: var(--success);
}
.step.failed .dot {
    background: var(--red);
}
.step-duration {
    margin-left: auto;
    font-size: 0.6875rem;
    color: var(--text-soft);
}
.step.done .step-duration {
    color: var(--success);
}
.step.failed .step-duration {
    color: var(--red);
}

.reply-footer {
    margin-top: -0.375rem;
    max-width: 88%;
}
.response-info {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--text-muted);
}
.response-info summary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.1875rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    list-style: none;
    cursor: pointer;
    transition: border-color 0.2s;
}
.response-info summary::-webkit-details-marker {
    display: none;
}
.response-info summary:hover,
.response-info[open] summary {
    border-color: var(--primary);
}
.response-time {
    color: var(--text);
    font-weight: 700;
}
.cached-badge {
    color: var(--primary-dark);
    font-weight: 700;
}
.usage {
    display: grid;
    gap: 0.25rem;
    margin: 0.5rem 0 0;
    padding: 0.625rem 0.75rem;
    background: var(--bg-muted);
    border-radius: var(--radius-small);
}
.usage li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}
.usage-value {
    color: var(--text);
    font-weight: 700;
}
.cached-message,
.no-model-calls-message {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-small);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
}
.cached-message {
    background: var(--primary-light);
    color: var(--primary-dark);
}
.no-model-calls-message {
    color: var(--text-muted);
}

.chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--border);
}
.chat-form input {
    flex: 1;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 0.625rem 1rem;
    background: var(--bg-muted);
    transition: border-color 0.2s, background 0.2s;
}
.chat-form input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg);
}
.chat-form button {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 999px;
    padding: 0.625rem 1.25rem;
    font-weight: 700;
    transition: background 0.2s;
}
.chat-form button:hover:not(:disabled) {
    background: var(--primary-dark);
}
.chat-form button:disabled {
    opacity: 0.5;
    cursor: default;
}
