/* ===== 全局重置与基础样式 ===== */

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

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --dark: #1e293b;
    --gray-900: #0f172a;
    --gray-800: #1e293b;
    --gray-700: #334155;
    --gray-600: #475569;
    --gray-500: #64748b;
    --gray-400: #94a3b8;
    --gray-300: #cbd5e1;
    --gray-200: #e2e8f0;
    --gray-100: #f1f5f9;
    --gray-50: #f8fafc;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.7;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}


/* ===== 顶部导航 ===== */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--gray-200);
    transition: all 0.3s ease;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.logo i {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.nav-link.active {
    background: var(--primary-bg);
    color: var(--primary);
}

.nav-link i {
    font-size: 14px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 8px 16px;
    min-width: 220px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.search-box:focus-within {
    background: var(--white);
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-box i {
    color: var(--gray-400);
    font-size: 14px;
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    font-size: 14px;
    width: 100%;
    color: var(--gray-800);
}

.search-box input::placeholder {
    color: var(--gray-400);
}


/* ===== 主内容区 ===== */

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 88px 24px 48px;
}


/* ===== 模块头部 ===== */

.module-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 32px;
    background: linear-gradient(135deg, var(--white) 0%, var(--primary-bg) 100%);
    border-radius: var(--radius-lg);
    margin-bottom: 32px;
    border: 1px solid var(--gray-200);
}

.module-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--white);
    font-size: 28px;
    flex-shrink: 0;
}

.module-info {
    flex: 1;
}

.module-info h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.module-info p {
    font-size: 15px;
    color: var(--gray-500);
}

.module-stats {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--gray-500);
}

.module-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.module-stats b {
    color: var(--primary);
    font-weight: 600;
}


/* ===== 字典条目区域 ===== */

.dictionary-section {
    display: flex;
    gap: 24px;
    position: relative;
}


/* 字母索引侧边栏 */

.dictionary-sidebar {
    width: 48px;
    flex-shrink: 0;
    position: sticky;
    top: 100px;
    align-self: flex-start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
}

.dictionary-sidebar::-webkit-scrollbar {
    width: 4px;
}

.dictionary-sidebar::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 2px;
}

.dictionary-letter-index {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
}

.letter-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    border: none;
    background: none;
    transition: all 0.2s ease;
}

.letter-btn:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.letter-btn.active {
    background: var(--primary);
    color: var(--white);
}

.letter-btn.empty {
    opacity: 0.3;
    cursor: default;
}

.letter-btn.empty:hover {
    background: none;
    color: var(--gray-500);
}


/* 字典内容区 */

.dictionary-content {
    flex: 1;
    min-width: 0;
}

.dictionary-group {
    margin-bottom: 32px;
}

.dictionary-group-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
    padding-left: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dictionary-group-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

.dictionary-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}


/* 字典条目卡片 */

.entry-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.entry-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform 0.25s ease;
    transform-origin: center;
}

.entry-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.entry-card:hover::before {
    transform: scaleY(1);
}

.entry-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}

.entry-term {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.entry-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.entry-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--primary-bg);
    color: var(--primary);
}

.entry-tag.green {
    background: #ecfdf5;
    color: var(--success);
}

.entry-tag.orange {
    background: #fff7ed;
    color: var(--accent);
}

.entry-tag.cyan {
    background: #ecfeff;
    color: var(--secondary);
}

.entry-summary {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.entry-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.entry-date {
    font-size: 12px;
    color: var(--gray-400);
}

.entry-read {
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.entry-read i {
    font-size: 11px;
    transition: transform 0.2s ease;
}

.entry-card:hover .entry-read i {
    transform: translateX(3px);
}


/* ===== 文章详情弹窗 ===== */

.article-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: none;
    align-items: stretch;
    justify-content: center;
}

.article-modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 800px;
    background: var(--white);
    overflow-y: auto;
    animation: slideUp 0.35s ease;
    display: flex;
    flex-direction: column;
    max-height: 100vh;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--gray-100);
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--gray-500);
}

.article-category {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--primary-bg);
    color: var(--primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-600);
    font-size: 16px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.modal-body {
    padding: 32px 40px 48px;
    flex: 1;
}

.article-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
    line-height: 1.4;
}

.article-subtitle {
    font-size: 16px;
    color: var(--gray-500);
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--gray-100);
}

.article-cover {
    width: 100%;
    border-radius: var(--radius);
    margin-bottom: 28px;
    overflow: hidden;
}

.article-cover img {
    width: 100%;
    display: block;
}

.article-section {
    margin-bottom: 28px;
}

.article-section h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 12px;
    padding-left: 14px;
    border-left: 4px solid var(--primary);
}

.article-section h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 10px;
    margin-top: 20px;
}

.article-section p {
    font-size: 15px;
    color: var(--gray-700);
    line-height: 1.8;
    margin-bottom: 14px;
}

.article-section ul,
.article-section ol {
    padding-left: 20px;
    margin-bottom: 14px;
}

.article-section li {
    font-size: 15px;
    color: var(--gray-700);
    line-height: 1.8;
    margin-bottom: 6px;
}


/* 代码块 */

.code-block {
    background: var(--gray-900);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin: 16px 0 20px;
    overflow-x: auto;
    position: relative;
}

.code-block::before {
    content: attr(data-lang);
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    font-weight: 600;
}

.code-block pre {
    margin: 0;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 13.5px;
    line-height: 1.7;
    color: #e2e8f0;
}

.code-block .keyword {
    color: #c084fc;
}

.code-block .string {
    color: #86efac;
}

.code-block .comment {
    color: #64748b;
    font-style: italic;
}

.code-block .function {
    color: #60a5fa;
}

.code-block .number {
    color: #fbbf24;
}

.code-block .operator {
    color: #f87171;
}


/* 行内代码 */

.inline-code {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    color: var(--primary);
}


/* 提示框 */

.tip-box {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-radius: var(--radius);
    margin: 16px 0;
}

.tip-box.info {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
}

.tip-box.warning {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
}

.tip-box.success {
    background: #f0fdf4;
    border-left: 4px solid #10b981;
}

.tip-box.danger {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
}

.tip-box i {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.tip-box.info i {
    color: #3b82f6;
}

.tip-box.warning i {
    color: #f59e0b;
}

.tip-box.success i {
    color: #10b981;
}

.tip-box.danger i {
    color: #ef4444;
}

.tip-box p {
    font-size: 14px !important;
    margin: 0 !important;
    color: var(--gray-700) !important;
}


/* 图文展示 */

.figure-block {
    margin: 20px 0;
    text-align: center;
}

.figure-block img {
    max-width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
}

.figure-block figcaption {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 8px;
    font-style: italic;
}


/* 表格 */

.article-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 20px;
    font-size: 14px;
}

.article-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    padding: 10px 16px;
    text-align: left;
    border-bottom: 2px solid var(--gray-200);
}

.article-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-600);
}

.article-table tr:hover td {
    background: var(--gray-50);
}


/* ===== 加载动画 ===== */

.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--white);
    gap: 16px;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading p {
    font-size: 14px;
    color: var(--gray-500);
}


/* ===== 空状态 ===== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 15px;
}


/* ===== 响应式 ===== */

@media (max-width: 900px) {
    .header-inner {
        gap: 12px;
    }
    .nav {
        display: none;
    }
    .search-box {
        min-width: 160px;
    }
    .module-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 24px;
    }
    .dictionary-section {
        flex-direction: column;
    }
    .dictionary-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }
    .dictionary-letter-index {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .dictionary-list {
        grid-template-columns: 1fr;
    }
    .modal-body {
        padding: 24px 20px 40px;
    }
    .modal-header {
        padding: 16px 20px;
    }
}

@media (max-width: 600px) {
    .main-content {
        padding: 80px 16px 32px;
    }
    .module-info h1 {
        font-size: 22px;
    }
    .article-title {
        font-size: 22px;
    }
    .search-box {
        display: none;
    }
}