/* =========================================
   SafeW 共享样式 / Design Tokens
   ========================================= */
:root {
  /* 颜色系统 */
  --color-dark: #13102D;
  --color-paper: #F7F5F3;
  --color-body: #171523;
  --color-brand: #2714EB;
  --color-accent: #89ED6E;

  /* 文本色变量（跟随容器自动切换） */
  --text-primary: var(--color-body);
  --text-secondary: rgba(23, 21, 35, 0.7);
  --text-link: var(--color-brand);
  --text-highlight: var(--color-brand);
  --bg-surface: var(--color-paper);
  --border-color: rgba(23, 21, 35, 0.16);

  /* 结构尺寸 */
  --radius-card: 24px;
  --radius-btn: 999px;
  --card-border: 1px solid rgba(23, 21, 35, 0.16);
  --card-shadow: none;
  --section-y: clamp(2.5rem, 5vw, 4rem);
  --gap: clamp(0.75rem, 1.5vw, 1.25rem);
  --content-max: 1120px;

  /* 字体 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 深色面覆盖 */
[data-theme="dark"] {
  --text-primary: var(--color-paper);
  --text-secondary: rgba(247, 245, 243, 0.8);
  --text-link: var(--color-accent);
  --text-highlight: var(--color-accent);
  --bg-surface: var(--color-dark);
  --border-color: rgba(247, 245, 243, 0.15);
}

/* 基础重置 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-surface);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--text-link); text-decoration: none; transition: color 0.2s ease; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }

/* 布局容器 */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  overflow-x: hidden;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 32px 24px;
  background: var(--bg-surface);
  border-right: var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 32px;
  z-index: 10;
  overflow-x: hidden;
}
.main-content {
  padding: var(--section-y) var(--gap);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  overflow-x: hidden;
}

/* 窄屏适配 */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: var(--card-border);
    padding: 16px 24px;
  }
  .sidebar .nav-list { display: flex; flex-wrap: wrap; gap: 16px; }
  .main-content { padding-top: var(--section-y); }
}

/* 品牌标识 */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}
.brand img { width: 32px; height: 32px; object-fit: contain; }

/* 导航 */
.nav-list { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  transition: background 0.2s, color 0.2s;
}
.nav-item:hover, .nav-item[aria-current="page"] {
  background: rgba(39, 20, 235, 0.08);
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
}
[data-theme="dark"] .nav-item:hover,
[data-theme="dark"] .nav-item[aria-current="page"] {
  background: rgba(137, 237, 110, 0.12);
  color: var(--color-accent);
}

/* 顶部导航（窄屏显示） */
.top-nav {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-surface);
  border-bottom: var(--card-border);
  padding: 12px 24px;
  align-items: center;
  justify-content: space-between;
}
@media (max-width: 960px) { .top-nav { display: flex; } }
.top-nav .brand { font-size: 1.1rem; }

/* 标题系统 */
.section-tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  color: var(--text-highlight);
}
[data-theme="dark"] .section-tag { color: var(--color-accent); }
h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
  color: var(--text-primary);
  text-wrap: balance;
}
h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: var(--gap) 0;
  color: var(--text-primary);
}
h3 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 24px 0 12px;
  color: var(--text-primary);
}
p { margin-bottom: 16px; max-width: 38em; }
.hl { color: var(--text-highlight); font-weight: 700; }

/* 按钮 */
.btn-group { display: flex; flex-wrap: wrap; gap: 16px; margin: 24px 0; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 28px;
  border-radius: var(--radius-btn);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  border: none;
  text-decoration: none;
}
.btn:focus-visible { outline: 3px solid var(--text-highlight); outline-offset: 2px; }
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: var(--color-accent);
  color: var(--color-dark);
}
.btn-primary:hover { background: #7ae05f; }
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--text-primary);
}
.btn-secondary:hover { background: rgba(23, 21, 35, 0.06); }
[data-theme="dark"] .btn-secondary { color: var(--color-paper); border-color: var(--color-paper); }
[data-theme="dark"] .btn-secondary:hover { background: rgba(247, 245, 243, 0.08); }

/* 面板与卡片 */
.panel {
  background: var(--bg-surface);
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: 32px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--gap); }
.card {
  background: var(--bg-surface);
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--card-shadow);
}
.card h3 { margin-top: 0; }
.card p { font-size: 0.95rem; margin-bottom: 0; }

/* 表格 */
.table-wrapper { overflow-x: auto; margin: 24px 0; border: var(--card-border); border-radius: var(--radius-card); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 16px 20px; text-align: left; border-bottom: var(--card-border); }
th { background: rgba(39, 20, 235, 0.05); font-weight: 700; }
[data-theme="dark"] th { background: rgba(137, 237, 110, 0.08); }
tr:last-child td { border-bottom: none; }

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: 12px; }
details {
  border: var(--card-border);
  border-radius: 16px;
  padding: 20px;
  background: var(--bg-surface);
}
summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
}
summary::-webkit-details-marker { display: none; }
summary::marker { display: none; }
summary::after {
  content: "+";
  margin-left: auto;
  font-weight: 400;
  transition: transform 0.2s;
}
details[open] summary::after { transform: rotate(45deg); }
details p { margin-top: 12px; color: var(--text-secondary); }

/* 步骤条 */
.steps { display: flex; flex-wrap: wrap; gap: 24px; counter-reset: step; }
.step-item { flex: 1 1 200px; position: relative; padding-left: 48px; }
.step-num {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  background: var(--color-accent);
  color: var(--color-dark);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
}
.step-title { font-weight: 700; margin-bottom: 8px; }
.step-desc { font-size: 0.95rem; color: var(--text-secondary); }

/* 场景标签 */
.scenario { border-left: 4px solid var(--color-brand); padding-left: 20px; margin-bottom: 32px; }
[data-theme="dark"] .scenario { border-left-color: var(--color-accent); }
.scenario-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(39, 20, 235, 0.1);
  color: var(--color-brand);
  margin-bottom: 8px;
}
[data-theme="dark"] .scenario-label { background: rgba(137, 237, 110, 0.15); color: var(--color-accent); }

/* 新闻网格 */
.news-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.news-card {
  background: var(--bg-surface);
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.news-card time { font-size: 0.85rem; color: var(--text-secondary); }
.news-card h3 { font-size: 1.1rem; margin: 0; }
.news-card p { font-size: 0.95rem; color: var(--text-secondary); margin: 0; }

/* 页脚 */
.footer {
  margin-top: var(--section-y);
  padding: 48px 24px;
  border-top: var(--card-border);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.footer a { margin: 0 12px; }

/* =========================================
   SVG 动效系统
   ========================================= */
.svg-container { width: 100%; height: auto; }
svg { width: 100%; height: auto; }

/* 星点明灭 */
@keyframes twinkle {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}
.svg-star { animation: twinkle 4s ease-in-out infinite alternate; }
.svg-star:nth-child(odd) { animation-delay: 1.2s; }
.svg-star:nth-child(3n) { animation-delay: 2.5s; }

/* 连线流动 (遵循 pathLength="1" 规则) */
@keyframes flow {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
.svg-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: flow 6s linear infinite;
}

/* 气泡上浮与悬浮 */
@keyframes float-up {
  0% { transform: translateY(8px); opacity: 0.8; }
  100% { transform: translateY(0); opacity: 1; }
}
@keyframes hover-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.svg-bubble { animation: float-up 0.8s ease-out forwards, hover-float 3s ease-in-out infinite 0.8s; }
.svg-bubble.delay-1 { animation-delay: 0.2s, 1s; }
.svg-bubble.delay-2 { animation-delay: 0.4s, 1.2s; }

/* 输入点呼吸 */
@keyframes breathe {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}
.svg-dot { animation: breathe 2s ease-in-out infinite; }
.svg-dot:nth-child(2) { animation-delay: 0.3s; }
.svg-dot:nth-child(3) { animation-delay: 0.6s; }

/* 通知滑入 */
@keyframes slide-in {
  from { transform: translateX(12px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.svg-notification { animation: slide-in 0.6s ease-out forwards; }

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .svg-line { stroke-dashoffset: 0; }
}

/* 旋转中心修正 */
.transform-origin-center { transform-box: fill-box; transform-origin: center; }
