/* 容器基础样式 */
.highlight {
    position: relative;
    margin: 1.5em 0;
    border-radius: 12px;
    background: #1e1e1e; /* 统一深色背景 */
    border: 1px solid #333;
    overflow: hidden; /* 保证圆角剪裁 */
    display: flex;
    flex-direction: column;
}

/* 顶部工具栏 - 实现吸顶的关键 */
.code-tools {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 34px;
    padding: 0 12px;
    background: rgba(45, 45, 45, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* 语言标签 */
.code-lang-name {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 现代感复制按钮 */
.copy-btn {
    background: rgba(255, 152, 0, 0.1);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: 6px;
    padding: 2px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: #ff9800;
    color: #fff;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.4);
}

/* 代码区域 */
.highlight pre {
    margin: 0 !important;
    padding: 15px !important;
    font-size: 14px;
    line-height: 1.6;
    overflow: auto !important;
    max-height: 400px;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 折叠控制：展开状态 */
.highlight.expanded pre {
    max-height: 2000px; /* 给一个足够大的高度 */
}

/* 底部展开遮罩按钮 */
.fold-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, rgba(30, 30, 30, 0.95));
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
    z-index: 15;
    cursor: pointer;
}

.highlight.expanded .fold-overlay {
    position: relative; /* 展开后变为相对定位，放在代码最下方 */
    background: transparent;
    height: 40px;
}

.fold-text {
    font-size: 12px;
    color: #888;
    background: #2a2a2a;
    padding: 4px 16px;
    border-radius: 20px;
    border: 1px solid #444;
    transition: all 0.2s;
}

.highlight .fold-overlay:hover .fold-text {
    color: #fff;
    border-color: #ff9800;
}

/* 滚动条美化 */
.highlight pre::-webkit-scrollbar { width: 6px; height: 6px; }
.highlight pre::-webkit-scrollbar-thumb { background: #444; border-radius: 10px; }
.highlight pre::-webkit-scrollbar-thumb:hover { background: #ff9800; }