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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222535;
  --border: #2a2d3e;
  --accent: #1d9bf0;
  --accent-dim: rgba(29,155,240,0.12);
  --text: #e7e9ea;
  --text-muted: #71767b;
  --text-dim: #3e4354;
  --green: #00ba7c;
  --red: #f4212e;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15,17,23,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

select:hover, select:focus {
  border-color: var(--accent);
}

.btn-refresh {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-refresh.spinning svg {
  animation: spin 0.7s linear infinite;
}

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

/* Status */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.cache-info {
  font-size: 12px;
  color: var(--text-dim);
}

/* Trends grid */
.trends-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding-bottom: 40px;
}

.trend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.trend-card:hover {
  border-color: #3a3d50;
}

.card-header {
  padding: 14px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-header .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.trend-list {
  list-style: none;
  padding: 8px 0;
}

.trend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  transition: background 0.15s;
}

.trend-item:hover {
  background: var(--surface2);
}

.rank {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 20px;
  text-align: right;
}

.trend-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}

.trend-name:hover {
  color: var(--accent);
}

/* Top 3 highlight */
.trend-item:nth-child(1) .rank { color: #ffd700; }
.trend-item:nth-child(2) .rank { color: #c0c0c0; }
.trend-item:nth-child(3) .rank { color: #cd7f32; }

/* Loading */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 16px;
  color: var(--text-muted);
}

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

.error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.error-state .error-icon { font-size: 40px; margin-bottom: 12px; }
.error-state p { margin-bottom: 16px; }
.error-state button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* Empty */
.empty-card {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: 15px;
}

@media (max-width: 600px) {
  .trends-container { grid-template-columns: 1fr; }
  .logo span { font-size: 16px; }
}
