/* 基础与变量 */
:root {
  --bg-deep: #0a0b0f;
  --bg-card: rgba(18, 20, 28, 0.85);
  --bg-card-hover: rgba(28, 32, 44, 0.9);
  --border: rgba(120, 140, 180, 0.25);
  --text: #e2e6ef;
  --text-muted: #8a94a8;
  --accent: #6b8cce;
  --accent-soft: rgba(107, 140, 206, 0.35);
  --star: rgba(255, 255, 255, 0.7);
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

/* 星空背景 */
.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% 0%, rgba(40, 55, 90, 0.4) 0%, transparent 50%),
    radial-gradient(ellipse 80% 50% at 80% 60%, rgba(60, 80, 120, 0.15) 0%, transparent 45%);
  pointer-events: none;
}

.stars::before,
.stars::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, var(--star), transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 90px 40px, var(--star), transparent),
    radial-gradient(2px 2px at 130px 80px, rgba(255, 255, 255, 0.4), transparent);
  background-repeat: repeat;
  background-size: 200px 150px;
  animation: twinkle 8s ease-in-out infinite;
}

.stars::after {
  background-size: 180px 120px;
  animation-delay: -3s;
  opacity: 0.7;
}

@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.page {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 1.5rem);
  padding-bottom: 3rem;
}

/* 头部 */
.header {
  text-align: center;
  padding: clamp(1.5rem, 5vw, 2.5rem) 0;
}

.title {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 1.85rem);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text);
}

.subtitle {
  margin: 0.35em 0 0;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  color: var(--text-muted);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 1.25rem;
  margin-top: 1rem;
}

.site-nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.site-nav-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* 通用模块与标题 */
.section-title {
  margin: 0 0 1rem;
  font-size: clamp(1.1rem, 3vw, 1.25rem);
  font-weight: 600;
  color: var(--text);
}

.module {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.module-placeholder {
  padding: 2rem;
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* 数据可视化大屏 */
.dashboard {
  margin-top: 1.5rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.stat-card {
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card-wide {
  grid-column: 1 / -1;
}

.stat-value {
  display: block;
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-bars {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.stat-bar-label {
  min-width: 4.5em;
  color: var(--text-muted);
}

.stat-bar-track {
  flex: 1;
  height: 1.25rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  min-width: 4px;
  background: linear-gradient(90deg, var(--accent), rgba(107, 140, 206, 0.6));
  border-radius: 999px;
  transition: width 0.5s ease-out;
}

.stat-bar-num {
  min-width: 2.2em;
  text-align: right;
  color: var(--text);
}

@media (min-width: 520px) {
  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .stat-card-wide {
    grid-column: span 2;
  }
}

@media (max-width: 380px) {
  .stat-value {
    font-size: 1.5rem;
  }
}

/* 工具栏 */
.toolbar {
  margin-bottom: 1.25rem;
}

.search-wrap {
  margin-bottom: 0.75rem;
}

.search {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='%238a94a8' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.75rem center;
}

.search::placeholder {
  color: var(--text-muted);
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.nav-btn {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.nav-btn.active {
  color: var(--bg-deep);
  background: var(--accent);
  border-color: var(--accent);
}

/* 卡片网格 */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
}

.card {
  display: block;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.card:hover,
.card:focus {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}

.card-tag {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
}

.card-hidden {
  display: none;
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: auto;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  cursor: pointer;
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.modal-title {
  margin: 0;
  padding: 1rem 1rem 0.5rem;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-weight: 600;
}

.modal-body {
  padding: 0 1rem 1rem;
  text-align: center;
}

.modal-img {
  max-width: 100%;
  height: auto;
  max-height: 75vh;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.modal-placeholder {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* 移动端优化 */
@media (max-width: 480px) {
  .cards {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .nav-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.75rem;
  }
}

/* 减少动画（尊重用户偏好） */
@media (prefers-reduced-motion: reduce) {
  .stars::before,
  .stars::after {
    animation: none;
  }

  .card:hover,
  .card:focus {
    transform: none;
  }

  .stat-bar-fill {
    transition: none;
  }
}
