/* GitHub 今日热门榜单 - 前端样式 */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #388bfd;
  --green: #3fb950;
  --gold: #d29922;
  --radius: 8px;
  --font-sans: "Noto Sans SC", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* Header */
.header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.title {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-icon {
  color: var(--accent);
  font-size: 1.25rem;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* 页面导航（GitHub / YouTube 两个页面切换） */
.nav-pages {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.nav-pages .nav-link {
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

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

.nav-pages .nav-link.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.input {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  min-width: 140px;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  padding: 8px 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-dim);
}

/* Meta */
.meta {
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.meta span + span::before {
  content: " · ";
}

/* List */
.main {
  min-height: 200px;
}

/* 确保带 hidden 的元素不显示，避免被 .loading 的 display 覆盖 */
[hidden] {
  display: none !important;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error {
  padding: 16px;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid #f85149;
  border-radius: var(--radius);
  color: #f85149;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display: block;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.item:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.item-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 12px;
  background: var(--bg);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.item-rank.top {
  background: linear-gradient(135deg, #d29922 0%, #b8860b 100%);
  color: #0d1117;
}

.item-rank.top-2 {
  background: linear-gradient(135deg, #8b949e 0%, #6e7681 100%);
  color: #fff;
}

.item-rank.top-3 {
  background: linear-gradient(135deg, #a0522d 0%, #8b4513 100%);
  color: #fff;
}

.item-header {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.item-name {
  font-weight: 600;
  color: var(--accent);
}

.item-lang {
  margin-left: 8px;
  padding: 2px 8px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.item-desc {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.item-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.item-stats strong {
  color: var(--green);
  font-family: var(--font-mono);
}

/* YouTube 卡片 */
.item-youtube {
  padding: 0;
  overflow: hidden;
}

.item-youtube-inner {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
}

.item-thumb-wrap {
  flex-shrink: 0;
  width: 160px;
  height: 90px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
}

.item-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.item-thumb-placeholder {
  width: 100%;
  height: 100%;
  background: var(--border);
}

.item-youtube-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.item-name-yt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
}

.item-channel {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.list-youtube .item-stats {
  margin-top: 2px;
}

@media (max-width: 640px) {
  .item-youtube-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .item-thumb-wrap {
    width: 100%;
    max-width: 320px;
    height: 180px;
  }
}

/* Footer */
/* 订阅日报 */
.subscribe-section {
  margin-top: 32px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.subscribe-title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.subscribe-desc {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.subscribe-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.subscribe-input {
  min-width: 200px;
  flex: 1;
}

.subscribe-msg {
  margin: 8px 0 0;
  font-size: 13px;
}

.subscribe-msg.success {
  color: var(--green);
}

.subscribe-msg.error {
  color: #f85149;
}

.subscribe-hint {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.subscribe-hint code {
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 11px;
}

.footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.footer code {
  padding: 2px 6px;
  background: var(--bg-card);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}
