:root {
  color-scheme: dark;
  --bg: #070b16;
  --panel: rgba(15, 23, 42, 0.78);
  --panel-strong: rgba(18, 27, 48, 0.95);
  --border: rgba(148, 163, 184, 0.18);
  --text: #e5eefc;
  --muted: #8ea0bd;
  --muted-2: #64748b;
  --accent: #6ee7f9;
  --accent-2: #a78bfa;
  --danger: #fb7185;
  --success: #34d399;
  --warning: #fbbf24;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(circle at 12% 5%, rgba(103, 232, 249, 0.16), transparent 34rem),
    radial-gradient(circle at 82% 0%, rgba(167, 139, 250, 0.16), transparent 32rem),
    linear-gradient(135deg, #050816 0%, #0b1020 52%, #090d19 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(rgba(255,255,255,.08) 0.75px, transparent 0.75px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}

a { color: inherit; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 28px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.78rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.subtitle {
  margin: 18px 0 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.75;
}

.status-card, .metric-card, .panel, .toolbar {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.status-card {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 260px;
  padding: 18px;
  border-radius: 22px;
}

.status-card strong { display: block; margin-bottom: 4px; }
.status-card small { color: var(--muted); }

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--muted-2);
  box-shadow: 0 0 0 6px rgba(100, 116, 139, 0.15);
}
.dot.loading { background: var(--warning); box-shadow: 0 0 0 6px rgba(251, 191, 36, .13); }
.dot.ok { background: var(--success); box-shadow: 0 0 0 6px rgba(52, 211, 153, .13); }
.dot.fail { background: var(--danger); box-shadow: 0 0 0 6px rgba(251, 113, 133, .14); }

.toolbar {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-radius: 26px;
  margin-bottom: 18px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-label {
  display: block;
  margin: 0 0 10px 4px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.tab, .refresh-btn, .error-state button {
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--text);
  background: rgba(30, 41, 59, 0.72);
  border-radius: 999px;
  padding: 11px 15px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.tab:hover, .refresh-btn:hover, .error-state button:hover { transform: translateY(-1px); border-color: rgba(110, 231, 249, .45); }
.tab.active { background: linear-gradient(135deg, rgba(110, 231, 249, .22), rgba(167, 139, 250, .22)); border-color: rgba(110, 231, 249, .55); color: white; }
.refresh-btn { white-space: nowrap; }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card {
  border-radius: 24px;
  padding: 18px 20px;
}
.metric-card span { display: block; color: var(--muted); margin-bottom: 10px; }
.metric-card strong { font-size: clamp(1.05rem, 2.4vw, 1.45rem); }

.panel {
  border-radius: 30px;
  padding: 20px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 4px 4px 18px;
}

.panel-head h2 { margin: 0 0 8px; font-size: 1.55rem; }
.panel-head p { margin: 0; color: var(--muted); line-height: 1.65; }
.source-link { color: var(--accent); text-decoration: none; font-weight: 800; white-space: nowrap; }

.state {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}
.state[hidden] { display: none; }
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(148, 163, 184, .2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state strong { color: var(--danger); font-size: 1.2rem; }
.error-state button { background: rgba(251, 113, 133, .12); }

.hot-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 18px;
}

.source-group {
  border: 1px solid rgba(148, 163, 184, .16);
  background: rgba(2, 6, 23, .22);
  border-radius: 26px;
  padding: 16px;
}

.source-group-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.source-group h3 {
  margin: 0 0 6px;
  font-size: 1.18rem;
}

.source-group p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.match-badge {
  flex: 0 0 auto;
  color: white;
  background: rgba(110, 231, 249, .13);
  border: 1px solid rgba(110, 231, 249, .28);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: .86rem;
  font-weight: 900;
  white-space: nowrap;
}

.match-badge.error {
  background: rgba(251, 113, 133, .12);
  border-color: rgba(251, 113, 133, .32);
  color: #fecdd3;
}

.source-hot-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.empty-topic {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px dashed rgba(148, 163, 184, .22);
  border-radius: 20px;
  color: var(--muted);
  background: rgba(15, 23, 42, .36);
}

.hot-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, .14);
  background: linear-gradient(135deg, rgba(15, 23, 42, .72), rgba(30, 41, 59, .36));
  border-radius: 22px;
}

.rank {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(110, 231, 249, .1);
  color: var(--accent);
  font-weight: 900;
}
.hot-item:nth-child(-n+3) .rank { background: linear-gradient(135deg, rgba(110, 231, 249, .24), rgba(167, 139, 250, .2)); color: white; }

.item-main { min-width: 0; }
.item-title { display: inline-block; color: white; text-decoration: none; font-weight: 800; line-height: 1.45; }
.item-title:hover { color: var(--accent); }
.item-desc { margin: 6px 0 0; color: var(--muted); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-match-info { margin: 6px 0 0; color: var(--accent); font-size: .82rem; line-height: 1.45; opacity: .82; }
.hot-score {
  color: #f8fafc;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: .88rem;
  white-space: nowrap;
}

.footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 34px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted-2);
  font-size: .92rem;
}
.footer a { color: var(--muted); }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; align-items: stretch; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .overview-grid { grid-template-columns: 1fr; }
  .panel-head { flex-direction: column; }
  .hot-item { grid-template-columns: 42px 1fr; }
  .hot-score { grid-column: 2; width: fit-content; }
  .footer { flex-direction: column; }
}

@media (max-width: 520px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 24px; }
  .tab { padding: 10px 12px; }
  .panel { padding: 14px; border-radius: 24px; }
  .hot-item { padding: 13px; }
}
