/* ===== CSS变量（浅色/深色） ===== */
:root {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-soft: #f1f5f9;
  --bg-nav: #ffffffcc;
  --border-color: #e2e8f0;
  --text-primary: #1f2937;
  --text-secondary: #334155;
  --text-heading: #0f172a;
  --text-link: #1d4ed8;
  --text-btn: #ffffff;
  --btn-bg: #2563eb;
  --btn-hover: #1d4ed8;
  --footer-bg: #0f172a;
  --footer-text: #e2e8f0;
  --footer-heading: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --radius: 16px;
  --max-width: 1280px;
  --transition: 0.2s ease;
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --gradient-hero: linear-gradient(145deg, #eef2ff 0%, #faf5ff 50%, #fdf2f8 100%);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

[data-theme="dark"] {
  --bg-body: #0b1120;
  --bg-card: #1e293b;
  --bg-soft: #1e293b;
  --bg-nav: #0f172aee;
  --border-color: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #cbd5e1;
  --text-heading: #f8fafc;
  --text-link: #93c5fd;
  --text-btn: #0f172a;
  --btn-bg: #e2e8f0;
  --btn-hover: #f1f5f9;
  --footer-bg: #0f172a;
  --footer-text: #cbd5e1;
  --footer-heading: #ffffff;
  --gradient-hero: linear-gradient(145deg, #0f172a 0%, #1e1b4b 50%, #2e1065 100%);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glow: 0 0 20px rgba(139, 92, 246, 0.2);
}

/* ===== 基础重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.7;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}
a { color: var(--text-link); text-decoration: none; transition: color 0.2s; }
a:hover { text-decoration: underline; color: var(--btn-hover); }
img, svg { max-width: 100%; display: block; }
ul, ol { padding-left: 1.5rem; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }

/* ===== 排版层级 ===== */
h1, h2, h3, h4 { color: var(--text-heading); font-weight: 700; line-height: 1.25; }
h1 { font-size: 2.5rem; margin-bottom: 1rem; background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
h2 { font-size: 2rem; margin: 2.5rem 0 1rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--border-color); position: relative; }
h2::after { content: ''; position: absolute; bottom: -2px; left: 0; width: 60px; height: 2px; background: var(--gradient-primary); }
h3 { font-size: 1.5rem; margin: 1.8rem 0 0.8rem; }
h4 { font-size: 1.2rem; margin: 1.2rem 0 0.5rem; }
p { margin-bottom: 1.2rem; }
.text-secondary { color: var(--text-secondary); }

/* ===== 头部导航 ===== */
.navbar {
  position: sticky; top: 0; z-index: 1000;
  background: var(--bg-nav);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  transition: box-shadow 0.3s;
}
.navbar:hover { box-shadow: var(--shadow-md); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; padding: 0.8rem 1.5rem; max-width: var(--max-width); margin: 0 auto; }
.logo { font-size: 1.8rem; font-weight: 800; color: var(--text-heading); display: flex; align-items: center; gap: 0.5rem; transition: transform 0.2s; }
.logo:hover { transform: scale(1.05); }
.logo svg { width: 36px; height: 36px; filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.3)); }
.nav-links { display: flex; gap: 2rem; align-items: center; }
.nav-links a { color: var(--text-primary); font-weight: 500; position: relative; }
.nav-links a::after { content: ''; position: absolute; bottom: -4px; left: 0; width: 0; height: 2px; background: var(--gradient-primary); transition: width 0.3s; }
.nav-links a:hover { color: var(--text-link); text-decoration: none; }
.nav-links a:hover::after { width: 100%; }
.menu-btn { display: none; background: none; border: 1px solid var(--border-color); padding: 0.3rem 1rem; border-radius: 30px; color: var(--text-primary); cursor: pointer; transition: all 0.3s; }
.menu-btn:hover { background: var(--bg-soft); }

/* ===== 按钮 ===== */
.btn {
  display: inline-block; background: var(--gradient-primary); color: var(--text-btn);
  padding: 0.6rem 1.8rem; border-radius: 40px; font-weight: 600;
  border: none; cursor: pointer; transition: all var(--transition);
  box-shadow: var(--glow);
  background-size: 200% auto;
}
.btn:hover { background-position: right center; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); text-decoration: none; }

/* ===== 卡片 ===== */
.card { background: var(--bg-card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); transition: transform 0.3s, box-shadow 0.3s; position: relative; overflow: hidden; }
.card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient-primary); opacity: 0; transition: opacity 0.3s; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md), var(--glow); }
.card:hover::before { opacity: 1; }

/* ===== 网格 ===== */
.grid { display: grid; gap: 1.8rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ===== Hero 区域 ===== */
.hero { padding: 4rem 0; background: var(--gradient-hero); position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; top: -50%; right: -20%; width: 600px; height: 600px; background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%); border-radius: 50%; }
.hero::after { content: ''; position: absolute; bottom: -30%; left: -10%; width: 400px; height: 400px; background: radial-gradient(circle, rgba(217, 70, 239, 0.08) 0%, transparent 70%); border-radius: 50%; }
.hero-content { display: flex; flex-wrap: wrap; gap: 2rem; align-items: center; position: relative; z-index: 1; }
.hero-text { flex: 1 1 400px; }
.hero-text h1 { font-size: 3rem; margin-bottom: 1.5rem; }
.hero-text p { font-size: 1.2rem; line-height: 1.8; }
.hero-video { flex: 1 1 300px; background: var(--glass-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 24px; padding: 1rem; box-shadow: var(--shadow-md), var(--glow); border: 1px solid var(--glass-border); }

/* ===== 轮播 ===== */
.carousel { position: relative; overflow: hidden; border-radius: 16px; }
.slides { display: flex; transition: transform 0.5s ease; }
.slide { min-width: 100%; }
.carousel-btn { position: absolute; top: 50%; transform: translateY(-50%); background: var(--btn-bg); color: var(--text-btn); border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; z-index: 10; transition: all 0.3s; opacity: 0.8; }
.carousel-btn:hover { opacity: 1; transform: translateY(-50%) scale(1.1); background: var(--btn-hover); }
.prev { left: 10px; } .next { right: 10px; }

/* ===== FAQ ===== */
.faq-item { border-bottom: 1px solid var(--border-color); padding: 1rem 0; transition: background 0.3s; }
.faq-item:hover { background: var(--bg-soft); padding-left: 0.5rem; padding-right: 0.5rem; }
.faq-question { display: flex; justify-content: space-between; cursor: pointer; font-weight: 600; color: var(--text-heading); transition: color 0.3s; }
.faq-question:hover { color: var(--text-link); }
.faq-answer { margin-top: 0.8rem; color: var(--text-primary); }

/* ===== 返回顶部 ===== */
.to-top { position: fixed; bottom: 2rem; right: 2rem; background: var(--gradient-primary); color: var(--text-btn); width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: all 0.3s; z-index: 999; border: none; box-shadow: var(--glow); }
.to-top:hover { transform: translateY(-4px); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.to-top.show { opacity: 1; }

/* ===== 页脚 ===== */
footer { background: var(--footer-bg); color: var(--footer-text); padding: 2.5rem 1.5rem; margin-top: 4rem; position: relative; }
footer::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient-primary); }
footer a { color: var(--footer-text); transition: color 0.3s; }
footer a:hover { color: var(--text-link); }
footer h4 { color: var(--footer-heading); }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 2rem; }

/* ===== 滚动动画 ===== */
.grid > .card, .hero-content, .faq-item {
  animation: fadeInUp 0.6s ease both;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.grid > .card:nth-child(1) { animation-delay: 0.1s; }
.grid > .card:nth-child(2) { animation-delay: 0.2s; }
.grid > .card:nth-child(3) { animation-delay: 0.3s; }
.grid > .card:nth-child(4) { animation-delay: 0.4s; }
.grid > .card:nth-child(5) { animation-delay: 0.5s; }
.grid > .card:nth-child(6) { animation-delay: 0.6s; }
.grid > .card:nth-child(7) { animation-delay: 0.7s; }
.grid > .card:nth-child(8) { animation-delay: 0.8s; }
.grid > .card:nth-child(9) { animation-delay: 0.9s; }
.grid > .card:nth-child(10) { animation-delay: 1s; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  .hero-text h1 { font-size: 2.2rem; }
  .hero { padding: 2.5rem 0; }
  .nav-links { display: none; flex-direction: column; gap: 1rem; background: var(--bg-card); position: absolute; top: 100%; left: 0; right: 0; padding: 1rem 2rem; box-shadow: var(--shadow-md); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
  .nav-links.active { display: flex; }
  .menu-btn { display: inline-block; }
  .grid { grid-template-columns: 1fr; }
  .to-top { bottom: 1rem; right: 1rem; width: 40px; height: 40px; }
  .container { padding: 0 1rem; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
  .btn { padding: 0.5rem 1.2rem; font-size: 0.9rem; }
  .hero-text p { font-size: 1rem; }
  .nav-inner { padding: 0.6rem 1rem; }
  .logo { font-size: 1.4rem; }
  .logo svg { width: 28px; height: 28px; }
}

/* ===== 暗色模式过渡 ===== */
body, .navbar, .card, .hero, footer, .to-top, .btn {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-soft); }
::-webkit-scrollbar-thumb { background: var(--gradient-primary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--btn-hover); }

/* ===== 文章卡片特殊样式 ===== */
article.card h4 { font-size: 1.1rem; }
article.card a { display: inline-block; margin-top: 0.5rem; font-weight: 500; }
article.card a:hover { transform: translateX(4px); }

/* ===== Blockquote ===== */
blockquote { border-left: 4px solid var(--btn-bg); padding: 1rem 1.5rem; background: var(--bg-soft); border-radius: 0 8px 8px 0; font-style: italic; }

/* ===== 联系卡片 ===== */
#contact .card { text-align: center; }
#contact .card h4 { color: var(--text-link); }

/* ===== 知识库文章 ===== */
#knowledge .card { display: flex; flex-direction: column; }
#knowledge .card p { flex-grow: 1; }

/* ===== FAQ 动画 ===== */
.faq-answer { overflow: hidden; transition: max-height 0.3s ease; }

/* ===== 焦点状态 ===== */
a:focus, button:focus, .faq-question:focus { outline: 2px solid var(--btn-bg); outline-offset: 2px; }

/* ===== 打印样式 ===== */
@media print {
  .navbar, .to-top, .carousel-btn, .menu-btn, #themeToggle { display: none; }
  body { background: white; color: black; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}