/* Markdown styling for compact assistant messages */
.assistant-message {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    line-height: 1.3;
    color: hsl(var(--primary) / 90%);
}

/* 标题样式保持不变 */
.assistant-message h1,
.assistant-message h2,
.assistant-message h3,
.assistant-message h4,
.assistant-message h5,
.assistant-message h6 {
    margin-top: 0.25em;
    margin-bottom: 0.25em;
    font-weight: 700;
    color: hsl(var(--primary) / 100%);
}

.assistant-message h1 { font-size: 1.5em; }
.assistant-message h2 { font-size: 1.3em; }
.assistant-message h3 { font-size: 1.15em; }
.assistant-message h4,
.assistant-message h5,
.assistant-message h6 { font-size: 1em; }

.assistant-message p {
    margin: 0 0 0.25em 0;
}

.assistant-message p + ul,
.assistant-message p + ol {
    margin-top: 0.1em;
}

.assistant-message ul,
.assistant-message ol {
    margin: 0.1em 0 0.25em 1.25em;
    padding: 0;
}

.assistant-message ul { list-style-type: disc; }
.assistant-message ol { list-style-type: decimal; }

.assistant-message li {
    margin-bottom: 0.15em;
}

.assistant-message li p {
    margin: 0.15em 0;
}

.assistant-message li > ul,
.assistant-message li > ol {
    margin: 0.1em 0 0 1em;
}

.assistant-message li:last-child {
    margin-bottom: 0;
}

/* 行内代码：确保有背景色 */
.assistant-message code {
    font-family: "IBMPlexMono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background-color: hsl(var(--color-dove) / 20%);
    padding: 0.15em 0.35em;
    border-radius: 0.25rem;
    font-size: 0.875em;
    color: #333;
}

/* 代码块容器 */
.assistant-message pre {
    position: relative;
    background-color: #f8f9fa;
    margin: 1em 0;
    border-radius: 6px;
    overflow: hidden;
}

/* 代码块顶部栏 */
.assistant-message pre::before {
    content: "";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2.5em;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    z-index: 1;
}

/* 代码块内的代码样式 */
.assistant-message pre code {
    display: block;
    background-color: transparent;
    padding: 2.5em 0.75em 0.75em;
    border-radius: 0;
    font-size: 0.875em;
    color: #333;
    line-height: 1.5;
}

/* 复制按钮样式 */
.assistant-message pre .copy-button {
    position: absolute;
    top: 0.5em;
    right: 1em;
    z-index: 2;
    background-color: transparent;
    color: #666;
    padding: 0.2em 0.5em;
    border-radius: 0.25rem;
    font-size: 0.75em;
    border: 1px solid #dee2e6;
    cursor: pointer;
    transition: all 0.2s ease;
}

.assistant-message pre .copy-button:hover {
    background-color: #e9ecef;
    color: #333;
}

.assistant-message pre .copy-button:active {
    transform: scale(0.95);
}

/* 暗色模式调整 */
@media (prefers-color-scheme: dark) {
    .assistant-message pre {
        background-color: #2d2d2d;
    }

    .assistant-message pre::before {
        background-color: #1a1a1a;
        border-bottom: 1px solid #404040;
    }

    .assistant-message pre code {
        color: #e0e0e0;
    }

    .assistant-message pre .copy-button {
        color: #e0e0e0;
        border-color: #404040;
        background-color: transparent;
    }

    .assistant-message pre .copy-button:hover {
        background-color: #404040;
        color: #ffffff;
    }
}

/* 其他样式保持不变 */
.assistant-message blockquote {
    border-left: 0.2rem solid hsl(var(--tw-prose-quote-borders, #e5e7eb));
    padding-left: 0.75em;
    color: hsl(var(--tw-prose-quotes, #555));
    font-style: italic;
    margin: 0 0 0.25em 0;
}

.assistant-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75em 0 1.25em 0;
    font-size: 0.875em;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background-color: #fff5e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.assistant-message th,
.assistant-message td {
    padding: 0.625em 1em;
    border-bottom: 1px solid #e5e7eb;
}

.assistant-message th {
    background-color: #f1f3f5;
    text-align: left;
    font-weight: 600;
    color: hsl(var(--primary) / 90%);
    white-space: nowrap;
    border-bottom: 2px solid #e5e7eb;
}

.assistant-message td:not(:last-child),
.assistant-message th:not(:last-child) {
    border-right: 1px solid #edf0f2;
}

.assistant-message tr:hover {
    background-color: #f1f3f5;
}

.assistant-message tr:last-child td {
    border-bottom: none;
}

@media (prefers-color-scheme: dark) {
    .assistant-message table {
        border-color: #404040;
        background-color: #2d2d2d;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }

    .assistant-message th,
    .assistant-message td {
        border-color: #404040;
    }

    .assistant-message th {
        background-color: #262626;
        color: #e0e0e0;
        border-bottom: 2px solid #404040;
    }

    .assistant-message td:not(:last-child),
    .assistant-message th:not(:last-child) {
        border-right: 1px solid #333333;
    }

    .assistant-message tr:hover {
        background-color: #333333;
    }
}

.assistant-message a {
    color: hsl(var(--link, #0366d6));
    text-decoration: none;
    font-weight: 500;
}

.assistant-message a:hover {
    text-decoration: underline;
    color: hsl(var(--link) / 80%);
}

.assistant-message img {
    max-width: 100%;
    height: auto;
    margin: 0 0 0.25em 0;
}