:root {
    --color-primary: #334155;
    --color-secondary: #64748b;
    --color-accent: #0ea5e9;
    --color-background: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
}

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Merriweather', Georgia, serif;
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.font-serif {
    font-family: 'Playfair Display', Georgia, serif;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Algorithm card styles */
.algorithm-card {
    animation: slideUp 0.6s ease forwards;
    opacity: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.algorithm-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.1);
}

/* Card staggering animation */
.algorithm-card:nth-child(1) { animation-delay: 0.1s; }
.algorithm-card:nth-child(2) { animation-delay: 0.15s; }
.algorithm-card:nth-child(3) { animation-delay: 0.2s; }
.algorithm-card:nth-child(4) { animation-delay: 0.25s; }
.algorithm-card:nth-child(5) { animation-delay: 0.3s; }
.algorithm-card:nth-child(6) { animation-delay: 0.35s; }
.algorithm-card:nth-child(7) { animation-delay: 0.4s; }
.algorithm-card:nth-child(8) { animation-delay: 0.45s; }
.algorithm-card:nth-child(9) { animation-delay: 0.5s; }
.algorithm-card:nth-child(10) { animation-delay: 0.55s; }

/* View button styles */
.active-view {
    background-color: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    font-weight: 600;
}

/* Algorithm info section */
.algorithm-info {
    animation: fadeIn 0.8s ease forwards;
    opacity: 0;
}

/* Table row hover */
#algorithm-list tr:hover {
    background-color: rgba(0,0,0,0.02);
}

/* Modal animation */
#algorithm-detail.show {
    animation: fadeIn 0.3s ease forwards;
}

#algorithm-detail .bg-white {
    animation: slideUp 0.4s ease forwards;
}

/* Code block base styles */
.code-block {
    position: relative;
    background: #282a36;
    color: #f8f8f2;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    counter-reset: line;
}

/* Code block line numbers */
.code-block > code {
    display: grid;
    width: 100%;
}

.code-block > code > span {
    counter-increment: line;
    padding-left: 2.5rem;
    position: relative;
    white-space: pre;
    display: block;
}

.code-block > code > span::before {
    content: counter(line);
    position: absolute;
    left: 0.75rem;
    color: #6272a4;
    text-align: right;
    width: 1rem;
}

/* Code block header (language label) */
.code-block::before {
    content: 'JavaScript';
    position: absolute;
    top: 0;
    left: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: #f8f8f2;
    padding: 0.2rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 0 0 4px 4px;
    z-index: 1;
}

/* Copy button */
.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #f8f8f2;
    padding: 0.2rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    z-index: 2;
}

.code-block:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 使用 highlight.js 实现代码高亮

从您分享的图片来看，当前的代码高亮效果确实不够理想。使用 highlight.js 是一个很好的选择，它提供了丰富的语法高亮功能和多种主题。

以下是实现步骤：

## 1. 首先修改 styles.css 文件
```css
/* ... 现有代码 ... */

/* 移除旧的代码高亮样式 */
/* Code syntax highlighting - 这些可以删除或注释掉 */
/*
.code-block .keyword { color: #ff79c6; }
.code-block .function { color: #50fa7b; }
.code-block .string { color: #f1fa8c; }
.code-block .number { color: #bd93f9; }
.code-block .comment { color: #6272a4; font-style: italic; }
.code-block .operator { color: #ff79c6; }
.code-block .variable { color: #f8f8f2; }
.code-block .parameter { color: #ffb86c; }
*/

/* 调整代码块样式以适应 highlight.js */
.code-block {
    position: relative;
    background: #282a36;
    color: #f8f8f2;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    padding: 1.5rem 0.5rem 1.5rem 3rem; /* 调整左侧padding以适应行号 */
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* 行号样式 */
.hljs-line-numbers {
    position: absolute;
    left: 0;
    top: 1.5rem;
    bottom: 1.5rem;
    width: 2.5rem;
    text-align: right;
    padding-right: 0.5rem;
    color: #6272a4;
    font-size: 0.875rem;
    line-height: 1.6;
    user-select: none;
    border-right: 1px solid rgba(98, 114, 164, 0.3);
}

/* 语言标签 */
.code-language-tag {
    position: absolute;
    top: 0;
    left: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: #f8f8f2;
    padding: 0.2rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 0 0 4px 4px;
    z-index: 1;
}

/* 复制按钮 */
.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #f8f8f2;
    padding: 0.2rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
    z-index: 2;
}

.code-block:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Code block header (JavaScript label) */
.code-block::before {
    content: 'JavaScript';
    position: absolute;
    top: 0;
    left: 1rem;  /* Changed from right to left */
    background: rgba(255, 255, 255, 0.1);
    color: #f8f8f2;
    padding: 0.2rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 0 0 4px 4px;
}

/* Code block line numbers */
.code-block {
    counter-reset: line;
}

.code-block > code {
    display: grid;
}

.code-block > code > span {
    counter-increment: line;
    padding-left: 2rem;
}

.code-block > code > span::before {
    content: counter(line);
    position: absolute;
    left: 0.75rem;
    color: #6272a4;
    text-align: right;
    width: 1rem;
}

/* Code block selection */
.code-block ::selection {
    background: rgba(255, 255, 255, 0.2);
}

/* Scrollbar styles for code blocks */
.code-block::-webkit-scrollbar {
    height: 6px;
}

.code-block::-webkit-scrollbar-track {
    background: #282a36;
}

.code-block::-webkit-scrollbar-thumb {
    background: #44475a;
    border-radius: 3px;
}

.code-block::-webkit-scrollbar-thumb:hover {
    background: #6272a4;
}

/* Copy button */
.code-block .copy-button {
    position: absolute;
    top: 0.5rem;
    right: 1rem;  /* Changed from 5rem to 1rem */
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #f8f8f2;
    padding: 0.2rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.code-block:hover .copy-button {
    opacity: 1;
}

.code-block .copy-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Algorithm complexity tags */
.complexity-badge {
    display: inline-flex;
    align-items: center;
    background: #282a36;
    color: #f8f8f2;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

.complexity-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.complexity-badge.time::before {
    background: #50fa7b;
}

.complexity-badge.space::before {
    background: #ff79c6;
}

/* 新的代码块样式 */

.complexity-badge.time {
    background-color: #1e293b;
    color: #ffffff;
}

.complexity-badge.space {
    background-color: #334155;
    color: #ffffff;
}

/* 确保 KaTeX 在各种环境下都能正确显示 */
.katex {
    font-size: 1em !important;
    font-family: KaTeX_Main, 'Times New Roman', serif !important;
}


/* Complexity tags */
.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    margin-right: 0.5rem;
    font-weight: 500;
}

.tag-blue {
    background-color: #dbeafe;
    color: #1e40af;
}

.tag-green {
    background-color: #dcfce7;
    color: #166534;
}

.tag-yellow {
    background-color: #fef3c7;
    color: #92400e;
}

.tag-red {
    background-color: #fee2e2;
    color: #b91c1c;
}

.tag-purple {
    background-color: #f3e8ff;
    color: #6b21a8;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(100, 116, 139, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(100, 116, 139, 0.5);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .font-serif {
        font-size: 0.95em;
    }
}


/* ... 现有样式 ... */

/* 详情模态框中的代码块样式 - 确保复制按钮在右上角 */
#algorithm-detail .code-block {
    position: relative;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    background-color: #1e293b;
    overflow: hidden;
}

#algorithm-detail .code-block pre {
    margin: 0;
    padding: 1rem;
    overflow: auto;
    max-height: 350px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

#algorithm-detail .code-block code {
    color: #e2e8f0;
    background: transparent;
}

/* 修复复制按钮的位置 - 放在右上角 */
#algorithm-detail .copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.75rem;
    background-color: rgba(51, 65, 85, 0.7);
    color: #e2e8f0;
    border: none;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
    opacity: 0;
}

#algorithm-detail .code-block:hover .copy-button {
    opacity: 1;
}

#algorithm-detail .copy-button:hover {
    background-color: rgba(71, 85, 105, 0.9);
}

/* 确保详细视图中的代码块样式不受影响 */
#algorithm-info .info-code-block {
    position: relative;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    background-color: #1e293b;
    overflow: hidden;
    max-height: 350px;
}

#algorithm-info .info-code-pre {
    margin: 0;
    padding: 1rem 0 1rem 3.5rem;
    overflow: auto;
    max-height: 350px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

#algorithm-info .info-code-pre code {
    display: block;
    color: #e2e8f0;
    padding-right: 1rem;
}

#algorithm-info .info-line-numbers {
    position: absolute;
    top: 1rem;
    left: 0;
    width: 2.5rem;
    text-align: right;
    padding-right: 0.5rem;
    color: #64748b;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    user-select: none;
}

#algorithm-info .info-code-language {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.25rem 0.75rem;
    background-color: #334155;
    color: #e2e8f0;
    font-size: 0.75rem;
    border-bottom-left-radius: 0.25rem;
    z-index: 10;
}

#algorithm-info .info-copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.75rem;
    background-color: rgba(51, 65, 85, 0.7);
    color: #e2e8f0;
    border: none;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
    opacity: 0;
}

#algorithm-info .info-code-block:hover .info-copy-button {
    opacity: 1;
}

#algorithm-info .info-copy-button:hover {
    background-color: rgba(71, 85, 105, 0.9);
}