/* ==== 设计变量 & 颜色系统 (高可读性优先) ==== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #334155;
    --text-muted: #475569;
    --text-inverse: #f8fafc;
    --text-link: #1d4ed8;
    --border-color: #cbd5e1;
    --accent-color: #2563eb;
    --accent-contrast: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --nav-bg: rgba(255,255,255,0.95);
    --footer-bg: #1e293b;
    --footer-text: #e2e8f0;
    --footer-link: #bfdbfe;
    --code-bg: #f1f5f9;
    --gradient-hero: linear-gradient(135deg, #fef3c7, #fde68a, #fcd34d);
    --glass-bg: rgba(255,255,255,0.7);
    --glass-border: rgba(255,255,255,0.3);
    --hover-lift: translateY(-6px);
    --radius-lg: 20px;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-muted: #cbd5e1;
    --text-inverse: #0f172a;
    --text-link: #93c5fd;
    --border-color: #334155;
    --accent-color: #3b82f6;
    --accent-contrast: #0f172a;
    --nav-bg: rgba(15,23,42,0.95);
    --footer-bg: #0f172a;
    --footer-text: #cbd5e1;
    --footer-link: #93c5fd;
    --code-bg: #1e293b;
    --gradient-hero: linear-gradient(135deg, #1e293b, #0f172a, #1e3a8a);
    --glass-bg: rgba(30,41,59,0.7);
    --glass-border: rgba(148,163,184,0.2);
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

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.7;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-size: 16px;
    overflow-x: hidden;
}

/* 文字层级颜色强制清晰 */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

h1 {
    font-size: 2.4rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
h2 {
    font-size: 2rem;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.3rem;
    margin-top: 2.5rem;
    color: var(--text-primary);
    position: relative;
    display: inline-block;
}
h2::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--accent-color);
}
h3 {
    font-size: 1.5rem;
    margin-top: 1.8rem;
    color: var(--text-primary);
}
h4 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 600;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
    font-weight: 400;
    line-height: 1.8;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color 0.2s, opacity 0.2s;
    font-weight: 500;
}
a:hover {
    text-decoration: underline;
    color: var(--accent-color);
    opacity: 0.9;
}

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

/* 导航 */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s, box-shadow 0.3s;
}
.navbar:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}
.logo {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
}
.logo:hover {
    transform: scale(1.02);
}
.logo svg {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.nav-links {
    display: flex;
    gap: 1.8rem;
    align-items: center;
}
.nav-links a {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 1rem;
    padding: 0.4rem 0;
    position: relative;
    transition: color 0.2s;
}
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}
.nav-links a:hover {
    color: var(--accent-color);
    text-decoration: none;
}
.nav-links a:hover::after {
    width: 100%;
}
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s;
}
.menu-toggle:hover {
    background: var(--bg-secondary);
}
.search-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-secondary);
    border-radius: 30px;
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.3rem 0.5rem;
    outline: none;
    width: 140px;
    font-size: 0.95rem;
}
.search-box input::placeholder {
    color: var(--text-muted);
}
.search-box button {
    background: var(--accent-color);
    color: var(--accent-contrast);
    border: none;
    border-radius: 30px;
    padding: 0.3rem 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    font-size: 0.9rem;
}
.search-box button:hover {
    opacity: 0.85;
}
.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 0.3rem 0.8rem;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}
.theme-toggle:hover {
    background: var(--accent-color);
    color: var(--accent-contrast);
    border-color: var(--accent-color);
}

/* 移动端菜单 */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        background: var(--bg-primary);
        position: absolute;
        top: 60px;
        left: 0;
        padding: 1rem;
        gap: 0.8rem;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        animation: slideDown 0.3s ease;
    }
    .nav-links.active {
        display: flex;
    }
    .menu-toggle {
        display: block;
    }
    .search-box {
        display: none;
    }
    .nav-container {
        padding: 0.6rem 1rem;
    }
    .logo {
        font-size: 1.4rem;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero banner */
.hero {
    background: var(--gradient-hero);
    padding: 4rem 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}
.hero-content {
    display: flex;
    align-items: center;
    gap: 3rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}
.hero-text {
    flex: 1 1 300px;
}
.hero-text h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-text p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 500px;
}
.hero-badge {
    background: var(--accent-color);
    color: var(--accent-contrast);
    padding: 0.3rem 1rem;
    border-radius: 30px;
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(37,99,235,0.3);
    backdrop-filter: blur(4px);
}
.hero-image {
    flex: 1 1 300px;
    display: flex;
    justify-content: center;
}
.hero-image svg {
    max-width: 300px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 10px 30px rgba(0,0,0,0.1));
    transition: transform 0.3s;
}
.hero-image svg:hover {
    transform: scale(1.03) rotate(2deg);
}

/* 卡片 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.8rem;
    margin: 2.5rem 0;
}
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-color), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}
.card:hover {
    transform: var(--hover-lift);
    box-shadow: var(--shadow-md);
}
.card:hover::before {
    opacity: 1;
}
.card h3 {
    margin-top: 0.5rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
    font-size: 1.3rem;
}
.card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}
.card svg {
    margin-bottom: 0.8rem;
    transition: transform 0.3s;
}
.card:hover svg {
    transform: scale(1.1) rotate(5deg);
}

/* 文章/列表 */
.article-list {
    margin: 2rem 0;
}
.article-item {
    border-bottom: 1px solid var(--border-color);
    padding: 1.2rem 0;
    transition: padding-left 0.3s, background-color 0.3s;
    border-radius: 8px;
    padding-left: 0.5rem;
}
.article-item:hover {
    padding-left: 1.2rem;
    background: var(--bg-secondary);
}
.article-item h4 {
    margin-bottom: 0.3rem;
    font-size: 1.1rem;
}
.article-item h4 a {
    color: var(--text-primary);
}
.article-item h4 a:hover {
    color: var(--accent-color);
}
.article-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}
.article-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.article-meta span::before {
    content: '•';
    color: var(--accent-color);
}

/* FAQ */
.faq-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.faq-item:hover {
    border-color: var(--accent-color);
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}
.faq-question {
    background: var(--bg-secondary);
    padding: 1rem 1.2rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    transition: background-color 0.2s;
    user-select: none;
}
.faq-question:hover {
    background: var(--code-bg);
}
.faq-question span {
    transition: transform 0.3s;
    font-size: 1.2rem;
}
.faq-item.open .faq-question {
    background: var(--accent-color);
    color: var(--accent-contrast);
}
.faq-item.open .faq-question span {
    transform: rotate(180deg);
}
.faq-answer {
    padding: 1rem 1.2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: none;
    animation: fadeIn 0.3s ease;
}
.faq-item.open .faq-answer {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* HowTo */
.howto-steps {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.8rem;
    border-radius: var(--radius-lg);
    border-left: 6px solid var(--accent-color);
    margin: 1.5rem 0;
    box-shadow: var(--shadow-sm);
}
.howto-steps ol {
    padding-left: 1.5rem;
    color: var(--text-secondary);
    margin: 1rem 0;
}
.howto-steps ol li {
    margin-bottom: 0.8rem;
    line-height: 1.8;
    position: relative;
}
.howto-steps ol li::marker {
    color: var(--accent-color);
    font-weight: bold;
}
.howto-steps ul {
    list-style: none;
    padding-left: 0;
}
.howto-steps ul li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}
.howto-steps ul li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent-color);
    font-weight: bold;
}

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
th, td {
    border: 1px solid var(--border-color);
    padding: 0.9rem 1rem;
    text-align: left;
    color: var(--text-secondary);
}
th {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
}
tr {
    transition: background-color 0.2s;
}
tbody tr:hover {
    background: var(--code-bg);
}

/* Footer */
.footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    padding: 3rem 0 1.5rem;
    margin-top: 4rem;
    position: relative;
}
.footer a {
    color: var(--footer-link);
    transition: opacity 0.2s;
}
.footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}
.footer-bottom {
    border-top: 1px solid #334155;
    padding-top: 1.5rem;
    margin-top: 2rem;
    text-align: center;
    color: var(--footer-text);
    font-size: 0.9rem;
}
.footer h4 {
    color: #ffffff;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}
.footer p {
    color: var(--footer-text);
    line-height: 1.8;
}

/* 按钮 */
.btn {
    background: var(--accent-color);
    color: var(--accent-contrast);
    border: none;
    border-radius: 40px;
    padding: 0.8rem 2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(37,99,235,0.3);
    position: relative;
    overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37,99,235,0.4);
    text-decoration: none;
}
.btn:hover::after {
    width: 300px;
    height: 300px;
}
.btn:active {
    transform: translateY(0);
}

/* 返回顶部 */
#backTop {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--accent-color);
    color: var(--accent-contrast);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    cursor: pointer;
    display: none;
    z-index: 999;
    box-shadow: 0 4px 15px rgba(37,99,235,0.3);
    transition: all 0.3s;
    backdrop-filter: blur(4px);
}
#backTop:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(37,99,235,0.4);
}

/* 滚动动画 */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.7s, transform 0.7s;
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 暗黑模式调整 */
[data-theme="dark"] .card,
[data-theme="dark"] .faq-item {
    background: var(--glass-bg);
}
[data-theme="dark"] .footer {
    background: #0f172a;
}
[data-theme="dark"] .card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

/* 所有文字颜色强制可读 */
.text-muted {
    color: var(--text-muted) !important;
}
.text-primary {
    color: var(--text-primary) !important;
}
.text-secondary {
    color: var(--text-secondary) !important;
}
.bg-secondary {
    background-color: var(--bg-secondary) !important;
}
.border-light {
    border-color: var(--border-color) !important;
}

/* 图片SVG文字对比度 */
.svg-text {
    fill: var(--text-primary) !important;
}
.svg-bg {
    fill: var(--bg-secondary) !important;
}

/* 通用动画 */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* 响应式优化 */
@media (max-width: 1024px) {
    h1 {
        font-size: 2rem;
    }
    h2 {
        font-size: 1.8rem;
    }
    .hero-text h1 {
        font-size: 2.2rem;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 15px;
    }
    h1 {
        font-size: 1.8rem;
    }
    h2 {
        font-size: 1.5rem;
    }
    h3 {
        font-size: 1.3rem;
    }
    .hero {
        padding: 2.5rem 0;
    }
    .hero-text h1 {
        font-size: 1.8rem;
    }
    .hero-text p {
        font-size: 1rem;
    }
    .card-grid {
        gap: 1.2rem;
    }
    .card {
        padding: 1.5rem;
    }
    .footer-grid {
        gap: 1.5rem;
    }
    #backTop {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 42px;
        height: 42px;
        font-size: 1.3rem;
    }
    .container {
        padding: 0 15px;
    }
    table {
        font-size: 0.9rem;
    }
    th, td {
        padding: 0.7rem;
    }
}

@media (max-width: 480px) {
    .hero-content {
        gap: 1.5rem;
    }
    .hero-image svg {
        max-width: 200px;
    }
    .btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.95rem;
    }
    .faq-question {
        font-size: 0.95rem;
    }
    .article-meta {
        flex-direction: column;
        gap: 0.3rem;
    }
}

/* 打印优化 */
@media print {
    .navbar,
    .footer,
    #backTop,
    .theme-toggle,
    .menu-toggle,
    .search-box {
        display: none !important;
    }
    body {
        background: white;
        color: black;
    }
    .card,
    .faq-item,
    .howto-steps {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* 无障碍 - 焦点可见性 */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}