:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #059669;
    --accent-color: #d97706;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

[data-theme="dark"] {
    --primary-color: #60a5fa;
    --primary-dark: #3b82f6;
    --primary-light: #93c5fd;
    --secondary-color: #34d399;
    --accent-color: #fbbf24;
    --bg-color: #111827;
    --card-bg: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #6b7280;
    --border-color: #374151;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.8;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ====== Header ====== */
.header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.header .container {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 60px;
    flex-wrap: nowrap;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.logo .icon {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.logo .text {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    white-space: nowrap;
}

/* ====== Navigation ====== */
.nav {
    flex: 1;
    min-width: 0;
}
.nav-list {
    display: flex;
    list-style: none;
    gap: 4px;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
}
.nav-list a {
    display: block;
    padding: 6px 12px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    white-space: nowrap;
    transition: all 0.15s;
}
.nav-list a:hover {
    color: var(--primary-color);
    background: rgba(37,99,235,0.06);
    text-decoration: none;
}
.nav-list a.active {
    color: var(--primary-color);
    background: rgba(37,99,235,0.1);
    font-weight: 600;
}

/* ====== Search ====== */
.search-box {
    position: relative;
    flex-shrink: 0;
}
#search-input {
    width: 200px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--bg-color);
    color: var(--text-primary);
    transition: border-color 0.2s, width 0.2s;
}
#search-input:focus {
    border-color: var(--primary-color);
    width: 260px;
    outline: none;
}
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 320px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}
.search-results.active {
    display: block;
}
.search-result-header {
    padding: 8px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--text-primary);
    transition: background 0.1s;
}
.search-result-item:hover {
    background: rgba(37,99,235,0.06);
    text-decoration: none;
}
.search-result-index {
    width: 22px;
    height: 22px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}
.search-result-title {
    flex: 1;
    font-size: 0.85rem;
}
.search-result-title mark {
    background: #fef08a;
    color: #1f2937;
    border-radius: 2px;
    padding: 0 2px;
}
.search-result-url {
    font-size: 0.72rem;
    color: var(--text-muted);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-no-result {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ====== Theme Toggle ====== */
.theme-toggle {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-color);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: all 0.15s;
}
.theme-toggle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.mobile-menu-btn {
    display: none;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-color);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
}

/* ====== Hero ====== */
.hero {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #fff;
    padding: 60px 0;
    text-align: center;
}
.hero h1 {
    font-size: 2rem;
    margin-bottom: 12px;
}
.hero p {
    font-size: 1.05rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 24px;
}
.hero-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}
.btn-primary {
    background: #fff;
    color: var(--primary-color);
}
.btn-primary:hover {
    background: #f0f0f0;
    text-decoration: none;
}
.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.3);
    text-decoration: none;
}

/* ====== Sections ====== */
.section-title {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: var(--text-primary);
}
.courses, .features {
    padding: 50px 0;
}

/* ====== Course Grid ====== */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}
.course-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.course-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.course-card.highlight {
    border-color: var(--primary-color);
    border-width: 2px;
}
.course-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 16px;
}
.course-card h3 {
    font-size: 1.05rem;
    margin-bottom: 8px;
}
.course-card p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.course-link {
    display: inline-block;
    padding: 6px 16px;
    background: var(--primary-color);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s;
}
.course-link:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

/* ====== Feature Grid ====== */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}
.feature-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
}
.feature-icon {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: rgba(37,99,235,0.1);
    color: var(--primary-color);
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 12px;
}
.feature-item h4 {
    margin-bottom: 8px;
}
.feature-item p {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* ====== Footer ====== */
.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 30px 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 40px;
}

/* ====== Content Page ====== */
.content-page .container {
    max-width: 960px;
}
.page-header {
    text-align: center;
    padding: 30px 0 20px;
}
.page-header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}
.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ====== Content Section ====== */
.content-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    text-align: center;
}
.content-section h2 {
    font-size: 1.3rem;
    margin-bottom: 16px;
    padding-bottom: 10px;
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    color: var(--text-primary);
}
.content-section h3 {
    font-size: 1.05rem;
    margin: 16px 0 8px;
    color: var(--text-primary);
    text-align: center;
}
/* 文本内容左对齐，图片/标题居中 */
.content-section .info-box,
.content-section .warning-box,
.content-section .formula-box,
.content-section p,
.content-section ul,
.content-section ol,
.content-section table,
.content-section td,
.content-section th {
    text-align: left;
}

/* ====== Component Image ====== */
/*.component-img — 样式已统一到下方「元件图片统一大小」区块 */

/* ====== Info / Warning / Formula Boxes ====== */
.info-box {
    background: rgba(37,99,235,0.06);
    border-left: 4px solid var(--primary-color);
    padding: 16px 20px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 12px 0;
    font-size: 0.9rem;
}
.warning-box {
    background: rgba(217,119,6,0.08);
    border-left: 4px solid var(--accent-color);
    padding: 16px 20px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 12px 0;
    font-size: 0.9rem;
}
.formula-box {
    background: rgba(5,150,105,0.06);
    border-left: 4px solid var(--secondary-color);
    padding: 16px 20px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 12px 0;
    font-size: 0.9rem;
}

/* ====== Tables ====== */
.styled-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.88rem;
}
.styled-table th {
    background: var(--primary-color);
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
}
.styled-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}
.styled-table tr:nth-child(even) td {
    background: rgba(37,99,235,0.03);
}
[data-theme="dark"] .styled-table tr:nth-child(even) td {
    background: rgba(96,165,250,0.05);
}

/* ====== TOC (inline page TOC) ====== */
.toc {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 30px;
}
.toc h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}
.toc-category {
    margin-bottom: 10px;
}
.toc-category-title {
    font-size: 0.85rem;
    color: var(--primary-color);
    display: block;
    margin-bottom: 4px;
}
.toc-category.must-know .toc-category-title {
    color: #dc2626;
}
.toc-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.toc-list li a {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.toc-list li a:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    text-decoration: none;
}

/* ====== Symbol Cards ====== */
/*.symbol-box — 样式已统一到下方「元件图片统一大小」区块 */
/*.symbol-img — 样式已统一到下方「元件图片统一大小」区块 */
.symbol-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ====== Utility ====== */
.flex-center-gap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.icon-style {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.2rem;
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
    .header .container {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 16px;
        gap: 8px;
    }
    .nav {
        order: 3;
        width: 100%;
        display: none;
    }
    .nav.active {
        display: block;
    }
    .nav-list {
        flex-direction: column;
        gap: 2px;
    }
    .nav-list a {
        padding: 8px 12px;
    }
    .mobile-menu-btn {
        display: block;
    }
    .search-box {
        order: 2;
        flex: 1;
    }
    #search-input {
        width: 100%;
    }
    #search-input:focus {
        width: 100%;
    }
    .search-results {
        min-width: unset;
        left: -40px;
        right: -40px;
    }
    .hero h1 {
        font-size: 1.5rem;
    }
    .hero p {
        font-size: 0.9rem;
    }
    .course-grid {
        grid-template-columns: 1fr;
    }
    .feature-grid {
        grid-template-columns: 1fr;
    }
    .content-section {
        padding: 16px;
    }
    .styled-table {
        font-size: 0.8rem;
    }
    .styled-table th, .styled-table td {
        padding: 6px 8px;
    }
}

/* ====== Bookmark Button ====== */
.bookmark-btn {
    display: inline-block;
    cursor: pointer;
    font-size: 1rem;
    margin-left: 8px;
    color: var(--text-muted);
    transition: color 0.15s;
    vertical-align: middle;
}
.bookmark-btn:hover {
    color: var(--accent-color);
}
.bookmark-btn.bookmarked {
    color: var(--accent-color);
}

/* ====== Bookmarks Panel ====== */
.bm-toggle-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-color);
    color: var(--accent-color);
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: all 0.15s;
}
.bm-toggle-btn:hover {
    border-color: var(--accent-color);
}
.bookmarks-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 320px;
    max-height: 60vh;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    overflow: hidden;
}
.bm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}
.bm-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    padding: 0 4px;
}
.bm-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.bm-list {
    max-height: 50vh;
    overflow-y: auto;
}
.bm-item {
    display: block;
    padding: 10px 16px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}
.bm-item:hover {
    background: rgba(37,99,235,0.05);
    text-decoration: none;
}
.bm-title {
    display: block;
    font-size: 0.9rem;
}
.bm-page {
    font-size: 0.75rem;
    color: var(--text-muted);
}

mark.search-highlight {
    background: #fef08a;
    color: #1f2937;
    padding: 1px 3px;
    border-radius: 2px;
    scroll-margin-top: 80px;
}
[data-theme="dark"] mark.search-highlight {
    background: #854d0e;
    color: #fef3c7;
}

@media (max-width: 768px) {
    .bookmarks-panel { right: 8px; left: 8px; width: auto; }
}

/* ====== Category Dividers ====== */
.category-divider {
    margin: 40px 0 20px;
    padding: 12px 0;
    border-bottom: 2px solid var(--primary-color);
    position: relative;
}
.category-divider-title {
    display: inline-block;
    background: var(--primary-color);
    color: #fff;
    padding: 6px 20px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 1rem;
    font-weight: 600;
    position: relative;
    top: 2px;
}

/* ====== Fade-in Animations (Intersection Observer) ====== */
.fade-in-element {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    will-change: opacity, transform;
}
.fade-in-element.fade-in-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered delay for grid children */
.course-grid .fade-in-element:nth-child(2),
.feature-grid .fade-in-element:nth-child(2) { transition-delay: 0.08s; }
.course-grid .fade-in-element:nth-child(3),
.feature-grid .fade-in-element:nth-child(3) { transition-delay: 0.16s; }
.course-grid .fade-in-element:nth-child(4),
.feature-grid .fade-in-element:nth-child(4) { transition-delay: 0.24s; }
.course-grid .fade-in-element:nth-child(5),
.feature-grid .fade-in-element:nth-child(5) { transition-delay: 0.32s; }
.course-grid .fade-in-element:nth-child(6),
.feature-grid .fade-in-element:nth-child(6) { transition-delay: 0.40s; }

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .fade-in-element {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ====== Ctrl+K Search Hint ====== */
#search-input::placeholder {
    color: var(--text-muted);
}
.search-kbd-hint {
    display: inline-block;
    font-size: 0.7rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--text-muted);
    margin-left: 4px;
    font-family: inherit;
    pointer-events: none;
    vertical-align: middle;
    line-height: 1.4;
}
@media (max-width: 900px) {
    .search-kbd-hint { display: none; }
}

/* ====== 元件图片（居中、不并排、保持原始比例） ====== */
.component-img {
    max-width: 360px;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 16px auto;
    border-radius: var(--radius-md);
    background: var(--card-bg);
    padding: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.symbol-img {
    max-width: 360px;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 16px auto;
    border-radius: var(--radius-md);
    background: var(--card-bg);
    padding: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
/* 符号卡片：纵向排列、居中 */
.symbol-box {
    display: flex !important;
    flex-direction: column !important;
    align-items: center;
    justify-content: center;
    max-width: 400px;
    margin: 8px auto !important;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
}
.symbol-box > img {
    max-width: 360px;
    height: auto;
    object-fit: contain;
    display: block;
}
.symbol-label {
    text-align: center;
}
/* 确保不并排 */
.component-img + .component-img,
.symbol-img + .symbol-img {
    margin-top: 20px;
}
@media (max-width: 768px) {
    .component-img,
    .symbol-img,
    .symbol-box > img {
        max-width: 90vw;
    }
    .symbol-box {
        max-width: 90vw;
    }
}

/* ====== 其他页面目录样式（对齐components.html） ====== */
.toc {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.toc h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}
.toc-category {
    margin-bottom: 8px;
}
.toc-category-title {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 10px 0 6px;
    font-weight: 600;
}
.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
}
.toc-list li {
    margin: 0;
}
.toc-list a {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.82rem;
    color: var(--primary-color);
    background: rgba(37,99,235,0.06);
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}
.toc-list a:hover {
    background: rgba(37,99,235,0.15);
    text-decoration: none;
}
@media (max-width: 768px) {
    .toc {
        padding: 14px 16px;
    }
    .toc-list {
        gap: 4px;
    }
    .toc-list a {
        font-size: 0.78rem;
        padding: 3px 8px;
    }
}


/* ====== 阅读进度条 ====== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    z-index: 10000;
    transition: width 0.1s linear;
    box-shadow: 0 0 6px rgba(37,99,235,0.4);
}

/* ====== 自动目录导航（TOC） ====== */
.toc-sidebar {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    max-height: 70vh;
    overflow-y: auto;
    width: 220px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 900;
    font-size: 0.78rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}
.toc-sidebar::-webkit-scrollbar { width: 4px; }
.toc-sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }
.toc-sidebar::-webkit-scrollbar-track { background: transparent; }
.toc-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.toc-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    line-height: 1;
}
.toc-sidebar .toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: block;
}
.toc-sidebar .toc-list li {
    margin-bottom: 2px;
}
.toc-sidebar .toc-list a {
    display: block;
    padding: 4px 8px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.toc-sidebar .toc-list a:hover {
    color: var(--primary-color);
    background: rgba(37,99,235,0.05);
}
.toc-sidebar .toc-list a.toc-active {
    color: var(--primary-color);
    background: rgba(37,99,235,0.08);
    border-left-color: var(--primary-color);
    font-weight: 600;
}
.toc-sidebar .toc-list a.toc-level-3 {
    padding-left: 20px;
    font-size: 0.74rem;
}
/* TOC浮动按钮（移动端/收起时） */
.toc-fab {
    position: fixed;
    right: 20px;
    bottom: 80px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 901;
    display: none;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.toc-fab:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(37,99,235,0.35); }
@media (max-width: 1300px) {
    .toc-sidebar { display: none; }
    .toc-sidebar.toc-mobile-open {
        display: block;
        right: 8px;
        left: 8px;
        width: auto;
        top: auto;
        bottom: 70px;
        max-height: 50vh;
        transform: none;
    }
    .toc-fab { display: flex; }
}

/* ====== 回到顶部按钮改进 ====== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: var(--shadow-lg);
    z-index: 800;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    line-height: 1;
}
.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}
.back-to-top:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}
.back-to-top .top-arrow {
    font-size: 1.1rem;
    line-height: 1;
}
.back-to-top .top-percent {
    font-size: 0.55rem;
    font-weight: 600;
    margin-top: 1px;
    line-height: 1;
}

/* ====== Skip to Content（无障碍） ====== */
.skip-to-content {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: #fff;
    padding: 10px 24px;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-weight: 600;
    z-index: 10001;
    text-decoration: none;
    transition: top 0.2s;
}
.skip-to-content:focus {
    top: 0;
}

/* ====== 无障碍 Focus 样式 ====== */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ====== 打印样式 ====== */
@media print {
    .header, .footer, .back-to-top, .toc-sidebar, .toc-fab,
    .reading-progress, .bookmark-btn, .bm-toggle-btn, .theme-toggle,
    .mobile-menu-btn, .search-box, .skip-to-content, .nav { display: none !important; }
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 11pt;
        line-height: 1.6;
    }
    .main { margin-top: 0 !important; padding: 0 !important; }
    .container { max-width: 100% !important; padding: 0 !important; }
    .content-section {
        page-break-inside: avoid;
        break-inside: avoid;
        border: 1px solid #ddd;
        margin-bottom: 12pt;
        padding: 12pt;
    }
    .course-card, .feature-item, .symbol-card {
        border: 1px solid #ddd;
        box-shadow: none !important;
    }
    [data-theme] { --bg-color: #fff; --card-bg: #fff; --text-primary: #000; --text-secondary: #333; }
    img { max-width: 100% !important; page-break-inside: avoid; }
    a { color: #000 !important; text-decoration: underline; }
    a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
    h1, h2, h3, h4 { page-break-after: avoid; }
    table { page-break-inside: avoid; }
    .info-box, .warning-box { border: 1px solid #999; }
    .hero { background: none !important; padding: 20pt 0 !important; }
    .hero h1 { font-size: 18pt; }
    .courses, .features { padding: 0 !important; }
}

/* ====== 元件快速摘要卡片 ====== */
.quick-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    font-size: 0.88rem;
}
.quick-card-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.quick-card-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    min-width: 60px;
}
.quick-card-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ====== 返回目录浮动按钮 ====== */
.back-to-toc {
    position: fixed;
    left: 20px;
    bottom: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--secondary-color);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 800;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.back-to-toc.visible {
    opacity: 1;
    transform: translateY(0);
}
.back-to-toc:hover {
    background: #047857;
}

/* ====== 元件对比表格 ====== */
.compare-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.85rem;
}
.compare-table th {
    background: var(--primary-color);
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 60px;
    z-index: 10;
}
.compare-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}
.compare-table tr:nth-child(even) td {
    background: rgba(37,99,235,0.03);
}
[data-theme="dark"] .compare-table tr:nth-child(even) td {
    background: rgba(96,165,250,0.05);
}
.compare-table tr:hover td {
    background: rgba(37,99,235,0.08);
}

/* ====== 响应式补充 ====== */
@media (max-width: 768px) {
    .quick-card {
        grid-template-columns: 1fr 1fr;
        padding: 12px;
        gap: 8px;
    }
    .back-to-toc { left: 12px; bottom: 16px; width: 40px; height: 40px; }
}
