:root {
  --bg: #0f0a1f;
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.15);
  --pink: #ff6fb7;
  --light-pink: #ffd1e8;
  --purple: #7a5af8;
  --blue: #5ac8fa;
  --text: #f8f8ff;
  --muted: rgba(248, 248, 255, 0.7);
  --shadow: 0 20px 60px rgba(15, 10, 31, 0.4);
}

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

body {
  margin: 0;
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, #1a1035, #080510 70%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  /* 防止横向滚动 */
  max-width: 100vw;
  position: relative;
}

img {
  max-width: 100%;
  display: block;
  border-radius: 18px;
}

main {
  padding: 0 1.5rem 4rem;
  max-width: 1100px;
  margin: -4rem auto 0;
  /* 防止内容溢出 */
  width: 100%;
  overflow-x: hidden;
}

/* 倒计时区域 */
.countdown-section {
  margin-bottom: 3rem;
}

.tab-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.75rem 2rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--text);
}

.tab-btn.active {
  background: linear-gradient(120deg, var(--pink), var(--purple));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 111, 183, 0.3);
}

.countdown-section .card {
  max-width: 600px;
  margin: 0 auto;
}

.hero {
  text-align: center;
  padding: 6rem 1.5rem 8rem;
  background: linear-gradient(135deg, rgba(255, 111, 183, 0.2), rgba(122, 90, 248, 0.2)),
    url("../image/爱能让一切发生.png") center/cover;
  position: relative;
  isolation: isolate;
  /* 防止背景图导致的横向滚动 */
  width: 100vw;
  max-width: 100%;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(9, 6, 20, 0.7);
  z-index: -1;
}

h1 {
  font-family: "Great Vibes", cursive;
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  margin: 0.3rem 0 1rem;
}

p {
  line-height: 1.7;
  color: var(--muted);
  margin: 0.2rem 0 1rem;
}

.subtitle {
  max-width: 580px;
  margin: 0 auto 2rem;
}

.eyebrow {
  color: var(--light-pink);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 0.75rem;
  margin: 0;
}

.cta-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.85rem 2rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
  background: linear-gradient(120deg, var(--pink), var(--purple));
  color: #fff;
  box-shadow: var(--shadow);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
}

.btn:hover {
  transform: translateY(-2px);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
  /* 防止网格项导致的溢出 */
  width: 100%;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.milestone h2 {
  margin: 0.6rem 0 0.2rem;
}

#countdown {
  font-size: clamp(1.5rem, 6vw, 2.8rem);
  letter-spacing: 0.2rem;
}

.hint {
  font-size: 0.9rem;
}

.stats {
  display: flex;
  justify-content: space-between;
  margin: 1rem 0;
  padding: 0;
}

.stats div {
  text-align: left;
}

.stats dt {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  color: var(--light-pink);
}

.stats dd {
  font-size: 1.3rem;
  margin: 0.2rem 0 0;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin: 1.5rem 0 0;
  padding: 0;
}

.stats-grid div {
  text-align: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s ease, background 0.2s ease;
}

.stats-grid div:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
}

.stats-grid dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  color: var(--light-pink);
  margin-bottom: 0.5rem;
}

.stats-grid dd {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  background: linear-gradient(120deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.progress {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--pink), var(--purple));
  transition: width 0.5s ease;
}

.promise ul {
  padding-left: 1.1rem;
  margin: 0;
}

.promise li {
  margin-bottom: 0.6rem;
}

.section-title {
  text-align: center;
  margin-bottom: 2.5rem;
}

.timeline-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.timeline-card {
  padding: 1.8rem;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(255, 111, 183, 0.15), rgba(90, 200, 250, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tag {
  display: inline-flex;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  color: var(--light-pink);
  margin-bottom: 0.8rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.gallery-item {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.gallery-item figcaption {
  font-size: 0.9rem;
  color: var(--muted);
}

.gallery-item.wide {
  grid-column: span 2;
}

.gallery-item.tall .placeholder {
  height: 320px;
}

.placeholder {
  border-radius: 18px;
  min-height: 180px;
  display: grid;
  place-items: center;
  font-weight: 600;
  color: var(--text);
}

.pink {
  background: linear-gradient(135deg, #ff88c2, #ff6fb7);
}

.purple {
  background: linear-gradient(135deg, #c3a9ff, #7a5af8);
}

.blue {
  background: linear-gradient(135deg, #8fd6ff, #5ac8fa);
}

.playlist {
  padding: 2rem;
}

.music-player-container {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.music-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
}

.music-tab {
  background: rgba(255, 182, 193, 0.2);
  border: 1px solid rgba(255, 182, 193, 0.5);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  white-space: nowrap;
}

.music-tab:hover {
  background: rgba(255, 182, 193, 0.4);
  transform: translateY(-2px);
}

.music-tab.active {
  background: linear-gradient(45deg, #ffb6c1, #ff69b4);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 105, 180, 0.3);
}

.music-player {
  text-align: center;
}

.now-playing {
  margin-bottom: 1rem;
}

.current-song-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

#audioPlayer {
  width: 100%;
  outline: none;
}

/* 滚动条样式 */
.music-tabs::-webkit-scrollbar {
  width: 6px;
}

.music-tabs::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.music-tabs::-webkit-scrollbar-thumb {
  background: rgba(255, 182, 193, 0.5);
  border-radius: 3px;
}

.music-tabs::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 182, 193, 0.8);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .music-tabs {
    max-height: 150px;
    font-size: 0.8rem;
  }
  
  .music-tab {
    padding: 0.4rem 0.8rem;
  }
  
  .current-song-title {
    font-size: 1rem;
  }
}

@media (max-width: 700px) {
  main {
    padding: 0 1rem 3rem;
    /* 确保主内容区不会产生横向滚动 */
    max-width: 100%;
  }

  .gallery-item.wide {
    grid-column: span 1;
  }

  .music-card {
    flex-direction: column;
    align-items: flex-start;
    /* 确保在小屏幕上也不会溢出 */
    width: 100%;
    box-sizing: border-box;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 4rem 1rem 5rem;
  }
  h1 {
    font-size: clamp(2rem, 9vw, 3rem);
  }
  .subtitle {
    margin: 0 auto 1.4rem;
  }
  .cta-row {
    gap: 0.6rem;
  }
  .btn {
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
  }
  .card {
    padding: 1rem;
    /* 确保卡片在小屏幕上不会溢出 */
    width: 100%;
    box-sizing: border-box;
  }
  .section-title {
    margin-bottom: 1.5rem;
  }
  .stats {
    flex-direction: column;
    gap: 0.5rem;
  }
  .stats-grid {
    gap: 1rem;
  }
  .count-tab {
    padding: 0.9rem;
    font-size: 0.9rem;
  }
  .music-card {
    padding: 1rem;
  }
  .song-title {
    font-size: 1rem;
  }
  audio {
    width: 100%;
  }
  .letter p {
    font-size: 0.95rem;
    line-height: 1.85;
  }
}

/* 倒计时卡片重设计 */
.countdown-card {
  max-width: 540px;
  margin: 0 auto;
  padding-top: 0.5rem;
  /* 确保倒计时卡片不会溢出 */
  width: 100%;
  box-sizing: border-box;
}

.count-tabs {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.count-tab {
  flex: 1;
  padding: 0.7rem 0.8rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
}

.count-tab.active {
  color: var(--text);
}

.count-indicator {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 3px;
  width: 50%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink), var(--purple));
  box-shadow: 0 6px 14px rgba(255, 111, 183, 0.35);
  transform: translateX(0%);
  transition: transform 0.3s ease;
}

.count-viewport {
  overflow: hidden;
}

.count-panels {
  display: flex;
  width: 200%;
  transition: transform 0.4s ease;
  /* 防止面板内容溢出 */
  flex-shrink: 0;
}

.count-panel {
  width: 50%;
  padding-top: 0.6rem;
}

.count-panel h2 {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
}

.toc-sidebar {
  position: fixed;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10;
  /* 防止目录栏导致的横向滚动 */
  max-width: calc(100vw - 2rem);
}

.toc-sidebar.visible {
  opacity: 1;
  pointer-events: auto;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: 220px;
  /* 防止目录内容溢出 */
  max-width: min(220px, calc(100vw - 3rem));
}

.toc-item button {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  border-radius: 10px;
  cursor: pointer;
}

.toc-item button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.toc-item.active button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

/* 添加侧边栏切换按钮样式 */
.sidebar-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px 0 0 8px;
  width: 24px;
  height: 40px;
  cursor: pointer;
  z-index: 11;
  color: var(--text);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.ellipsis {
  text-align: center;
  font-size: 1.2rem;
  color: var(--muted);
}

@media (max-width: 480px) {
  .ellipsis {
    font-size: 2rem;
  }
  
}

@media (max-width: 700px) {
  .toc-sidebar {
    right: 0.5rem;
    left: auto;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }
  
  .toc-list {
    flex-direction: column;
    max-height: 70vh;
    overflow-y: auto;
    gap: 0.3rem;
  }
  
  .toc-item button {
    white-space: normal;
    padding: 0.6rem 0.8rem;
  }
}

footer {
  text-align: center;
  padding: 3rem 1.5rem;
  background: rgba(15, 10, 31, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.heart-divider {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.5rem;
}

.heart-divider::before,
.heart-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to var(--side, right), var(--pink), transparent);
}

.heart-divider::after {
  --side: left;
}

.heart {
  color: var(--pink);
  font-size: 1.8rem;
  margin: 0 1rem;
  animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

footer p {
  font-size: 1.1rem;
  color: var(--light-pink);
  margin: 0 0 1.5rem;
  font-weight: 500;
}

.footer-decoration {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pink);
  opacity: 0.7;
}

.dot:nth-child(2) {
  background: var(--purple);
  animation: pulse 2s infinite;
}

.dot:nth-child(3) {
  background: var(--blue);
  animation: pulse 2s infinite 0.5s;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
}

@media (max-width: 480px) {
  footer {
    padding: 0 1rem 2rem;
  }
  
  footer p {
    font-size: 1rem;
  }
  
  .heart {
    font-size: 1.5rem;
  }
}
