* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141415;
    --bg-tertiary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-color: #4a9eff;
    --accent-hover: #3a8eef;
    --border-color: #1a1a1a30;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

p {
    font-weight: 180;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 左侧侧边栏样式 */
.sidebar {
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
}

.sidebar-header h2 {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.4;
}

.folder-tree {
    padding: 15px;
    flex: 1;
}

.folder-item {
    padding: 10px 15px;
    margin: 5px 0;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.folder-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.folder-item.active {
    background-color: var(--accent-color);
    color: white;
}

.folder-item .count {
    margin-left: auto;
    font-size: 0.85rem;
    opacity: 0.7;
}

.folder-item .icon {
    font-size: 1.2rem;
}

/* 右侧主内容区域 */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 30px;
}

.content-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.content-header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.stats {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* 网格容器 */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* 资源卡片 */
.resource-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.resource-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    border-color: var(--accent-color);
}

.card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 3rem;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-info {
    padding: 15px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 5px;
    line-height: 1.4;
    height: 2.8em; /* Fallback for height */
}

.card-meta {
    display: none; /* Hide the old meta section if we are replacing it, or we can reuse it */
}

.card-meta .format {
    background-color: var(--bg-tertiary);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.card-meta .size {
    font-size: 0.8rem;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    min-height: 100%;
    box-sizing: content-box;
}

.modal-content {
    display: block;
    max-width: 90%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

.modal-info {
    text-align: center;
    padding: 20px;
    color: var(--text-primary);
    max-width: 800px;
    width: 100%;
}

.modal-info h1 {
    margin-bottom: 10px;
    font-size: 2rem;
    font-weight: bold;
    line-height: 1.3;
}

.modal-info h3 {
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.modal-info p {
    color: var(--text-secondary);
}

.modal-annotation {
    margin-top: 20px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    text-align: left;
    line-height: 1.6;
}

.modal-annotation h1,
.modal-annotation h2,
.modal-annotation h3,
.modal-annotation h4,
.modal-annotation h5,
.modal-annotation h6 {
    color: var(--text-primary);
    margin-top: 20px;
    margin-bottom: 10px;
}

.modal-annotation h1:first-child,
.modal-annotation h2:first-child,
.modal-annotation h3:first-child {
    margin-top: 0;
}

.modal-annotation p {
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.modal-annotation ul,
.modal-annotation ol {
    color: var(--text-secondary);
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-annotation li {
    margin-bottom: 5px;
}

.modal-annotation code {
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: var(--accent-color);
}

.modal-annotation pre {
    background-color: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 15px;
}

.modal-annotation pre code {
    background-color: transparent;
    padding: 0;
    color: var(--text-primary);
}

.modal-annotation a {
    color: var(--accent-color);
    text-decoration: none;
}

.modal-annotation a:hover {
    text-decoration: underline;
}

.modal-annotation blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 15px;
    margin: 15px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.modal-annotation table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.modal-annotation th,
.modal-annotation td {
    border: 1px solid var(--bg-tertiary);
    padding: 8px 12px;
    text-align: left;
}

.modal-annotation th {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-annotation img {
    max-width: 100%;
    border-radius: 8px;
    margin: 15px 0;
}

.close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.close:hover {
    color: var(--accent-color);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .main-content {
        margin-left: 240px;
    }

    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        max-height: 200px;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }

    .content-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }

    .card-image {
        height: 150px;
    }

    .card-info {
        padding: 10px;
    }

    .card-title {
        font-size: 0.9rem;
    }
}

/* 滚动条样式 */
.sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.sidebar::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* 加载动画 */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

/* Breadcrumb Styles */
.breadcrumb {
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.breadcrumb ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.breadcrumb li {
    display: flex;
    align-items: center;
}

.breadcrumb li:not(:last-child)::after {
    content: '/';
    margin: 0 10px;
    color: var(--text-secondary);
    opacity: 0.5;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.breadcrumb li:last-child {
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px; /* Limit width of the last item if title is too long */
}

@media (max-width: 768px) {
    .breadcrumb li:last-child {
        max-width: 150px;
    }
}

/* Detail Page Styles */
.detail-container {
    max-width: 1000px;
    margin: 0 auto;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.detail-header {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.detail-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 15px;
    line-height: 1.2;
}



.detail-image-wrapper {
    width: 100%;
    margin-bottom: 30px;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-tertiary);
    display: flex;
    justify-content: center;
}

.detail-image {
    max-width: 100%;
    max-height: 600px;
    object-fit: contain;
}

.detail-content {
    color: var(--text-secondary);
    line-height: 1.8;
}

.detail-content h1,
.detail-content h2,
.detail-content h3 {
    color: var(--text-primary);
    margin-top: 30px;
    margin-bottom: 15px;
}

.detail-content ul,
.detail-content ol {
    padding-left: 20px;
    margin-bottom: 20px;
}

.detail-content li {
    margin-bottom: 8px;
}

.detail-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.detail-content a:hover {
    text-decoration: underline;
}

.detail-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 15px;
    margin: 20px 0;
    font-style: italic;
    background-color: var(--bg-tertiary);
    padding: 15px;
    border-radius: 4px;
}

.back-nav {
    margin-bottom: 20px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-color);
}

.back-link::before {
    content: '←';
    margin-right: 8px;
}