:root {
  --bg: #09090b;
  --bg2: #0f0f14;
  --card: #18181b;
  --card-hover: #1f1f23;
  --text: #fafafa;
  --text2: #a1a1aa;
  --text3: #71717a;
  --accent: #8b5cf6;
  --accent2: #6366f1;
  --accent3: #ec4899;
  --border: #27272a;
  --border2: #3f3f46;
  --success: #10b981;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --glass: rgba(24,24,27,0.8);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.header {
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.logo { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(139,92,246,0.3);
}
.logo h1 { font-size: 1.25rem; font-weight: 700; background: linear-gradient(135deg, var(--accent), var(--accent3)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.logo p { font-size: 0.75rem; color: var(--text3); }

/* 顶部播放器 */
.music-player {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg2);
  border-radius: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.music-info { flex: 1; min-width: 0; }
.music-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-artist { font-size: 0.7rem; color: var(--text3); }
.music-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.music-btn-sm {
  width: 30px; height: 30px;
  border: none; background: var(--card);
  color: var(--text2); border-radius: 50%;
  cursor: pointer; font-size: 0.75rem;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.music-btn-sm:hover { background: var(--accent); color: white; }
.music-btn {
  width: 36px; height: 36px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  color: white; border-radius: 50%;
  cursor: pointer; font-size: 0.9rem;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(139,92,246,0.4);
}
.music-btn:hover { transform: scale(1.1); }
.volume-control {
  display: flex; align-items: center; gap: 4px;
  margin-left: 4px; padding-left: 8px;
  border-left: 1px solid var(--border2);
}
.volume-icon { font-size: 0.8rem; cursor: pointer; user-select: none; }
.volume-icon:hover { opacity: 0.7; }
#volume-slider {
  width: 50px; height: 3px;
  -webkit-appearance: none; appearance: none;
  background: var(--border2); border-radius: 2px;
  outline: none; cursor: pointer;
}
#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
#volume-slider::-moz-range-thumb {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: none;
}
.music-progress {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 2px; background: var(--border);
  border-radius: 0 0 12px 12px; overflow: hidden;
}
.music-progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent3)); width: 0%; transition: width 0.3s; }

.header-stats { display: flex; align-items: center; gap: 16px; font-size: 0.85rem; color: var(--text2); flex-shrink: 0; }
.stat-item { display: flex; align-items: center; gap: 6px; }
.stat-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.7;transform:scale(1.2)} }

.nav {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 64px;
  z-index: 99;
}
.nav-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 8px 0;
}
.nav-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  position: relative;
  white-space: nowrap;
}
.nav-btn::after {
  content: '';
  position: absolute;
  bottom: -8px; left: 50%;
  width: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent3));
  transition: all 0.3s;
  transform: translateX(-50%);
  border-radius: 1px;
}
.nav-btn:hover { color: var(--text); background: rgba(139,92,246,0.1); }
.nav-btn.active { color: var(--text); background: rgba(139,92,246,0.15); }
.nav-btn.active::after { width: 60%; }

.sub-nav {
  display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
.sub-nav-btn {
  padding: 6px 14px; border: 1px solid var(--border);
  background: var(--card); color: var(--text2);
  border-radius: 20px; cursor: pointer; font-size: 0.8rem;
  transition: all 0.2s;
}
.sub-nav-btn:hover { border-color: var(--accent); color: var(--text); }
.sub-nav-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent3)); border-color: transparent; color: white; }

.container { max-width: 1400px; margin: 0 auto; padding: 24px; }
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.section { margin-bottom: 40px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.section-title { font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.section-title .icon { width: 28px; height: 28px; background: linear-gradient(135deg, var(--accent), var(--accent3)); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; }

.refresh-btn {
  padding: 8px 16px; border: 1px solid var(--border2);
  background: var(--card); color: var(--text2);
  border-radius: 8px; cursor: pointer; font-size: 0.8rem;
  transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;
}
.refresh-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.refresh-btn.loading .refresh-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }

/* 技术页瀑布流 */
.cards.masonry {
  display: block !important;
  column-count: 3;
  column-gap: 20px;
}
.cards.masonry .card {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 20px !important;
  width: 100% !important;
  display: flex !important;
}
.cards.masonry .card-image { height: auto !important; max-height: 400px; object-fit: cover; }
.cards.masonry .card-image-placeholder { height: 120px !important; }
/* 无图卡片占位符错落高度，制造瀑布流效果 */
.cards.masonry .card:nth-child(5n+1) .card-image-placeholder { height: 170px !important; }
.cards.masonry .card:nth-child(5n+2) .card-image-placeholder { height: 100px !important; }
.cards.masonry .card:nth-child(5n+3) .card-image-placeholder { height: 140px !important; }
.cards.masonry .card:nth-child(5n+4) .card-image-placeholder { height: 110px !important; }
.cards.masonry .card:nth-child(5n) .card-image-placeholder { height: 150px !important; }
@media (max-width: 1024px) { .cards.masonry { column-count: 2; } }
@media (max-width: 640px) { .cards.masonry { column-count: 1; } }

.card {
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  opacity: 0;
  animation: cardIn 0.4s ease forwards;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-6px); border-color: var(--accent); box-shadow: var(--shadow), 0 0 0 1px var(--accent); }
@keyframes cardIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.card-image {
  width: 100%; height: 160px; object-fit: cover;
  background: linear-gradient(135deg, var(--bg2), var(--card));
  display: block; flex-shrink: 0;
}
.card-image-placeholder {
  width: 100%; height: 160px;
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; opacity: 0.8; flex-shrink: 0;
}
.card-content { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.card-tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 500; margin-bottom: 10px; align-self: flex-start; }
.tag-news { background: rgba(139,92,246,0.2); color: #a78bfa; }
.tag-tech { background: rgba(99,102,241,0.2); color: #818cf8; }
.tag-anime { background: rgba(236,72,153,0.2); color: #f472b6; }
.card-title { font-size: 0.95rem; font-weight: 600; line-height: 1.4; margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.card-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: var(--text3); margin-top: auto; }
.card-source { display: flex; align-items: center; gap: 6px; }
.card-source::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

.skeleton { background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { display: flex; flex-direction: column; gap: 12px; }
.skeleton-image { height: 160px; border-radius: 12px 12px 0 0; }
.skeleton-line { height: 14px; border-radius: 4px; }
.skeleton-line:nth-child(2) { width: 80%; }
.skeleton-line:nth-child(3) { width: 60%; margin-top: 8px; }

.anime-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
.anime-card {
  background: var(--card); border-radius: 16px; overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer; position: relative;
  opacity: 0; animation: cardIn 0.4s ease forwards;
}
.anime-card:hover { transform: translateY(-8px) scale(1.02); box-shadow: var(--shadow); border-color: var(--accent); }
.anime-cover { width: 100%; height: 220px; object-fit: cover; background: var(--bg2); display: block; }
.anime-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 12px; background: linear-gradient(transparent, rgba(0,0,0,0.9));
  opacity: 0; transition: opacity 0.3s;
}
.anime-card:hover .anime-overlay { opacity: 1; }
.anime-info { padding: 12px; }
.anime-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anime-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.7rem; color: var(--text3); }
.anime-rating { color: #fbbf24; font-weight: 600; }
.anime-rank { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,0.7); padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 700; z-index: 1; }

.back-to-top {
  position: fixed; bottom: 24px; right: 24px;
  width: 40px; height: 40px;
  background: var(--card); border: 1px solid var(--border2);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(20px);
  transition: all 0.3s; z-index: 99;
  color: var(--text2); font-size: 1.2rem;
}
.back-to-top.show { opacity: 1; transform: translateY(0); }
.back-to-top:hover { background: var(--accent); color: white; border-color: var(--accent); }

.error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; padding: 24px; border-radius: 12px; text-align: center; grid-column: 1 / -1; }
.empty { color: var(--text3); text-align: center; padding: 40px; grid-column: 1 / -1; font-size: 0.9rem; }

@media (max-width: 768px) {
  .header-content { flex-wrap: wrap; }
  .music-player { order: 3; flex-basis: 100%; max-width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .anime-grid { grid-template-columns: repeat(2, 1fr); }
  .back-to-top { right: 16px; bottom: 16px; }
  .volume-control { display: none; }
}