/* ===== CSS Variables & Reset ===== */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2236;
  --bg-card: #151d2e;
  --bg-card-hover: #1c2640;
  --bg-ticker: #050810;
  --text-primary: #e8ecf4;
  --text-secondary: #8899b4;
  --text-muted: #5a6a84;
  --accent: #00d4aa;
  --accent-hover: #00f0c0;
  --accent-dim: rgba(0, 212, 170, 0.12);
  --red: #ff4757;
  --green: #2ecc71;
  --yellow: #ffa502;
  --blue: #3498db;
  --border: #1e2a3f;
  --border-light: #253246;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --radius: 8px;
  --radius-sm: 5px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --header-height: 60px;
  --ticker-height: 32px;
}

[data-theme="light"] {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef1f6;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f4f8;
  --bg-ticker: #1a1f2e;
  --text-primary: #1a202c;
  --text-secondary: #5a6577;
  --text-muted: #9ca3af;
  --accent: #00a882;
  --accent-hover: #00c49a;
  --accent-dim: rgba(0, 168, 130, 0.1);
  --border: #e2e8f0;
  --border-light: #edf2f7;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ===== Ticker Bar ===== */
.ticker-bar {
  height: var(--ticker-height);
  background: var(--bg-ticker);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.ticker-content {
  display: flex;
  align-items: center;
  height: 100%;
  animation: ticker-scroll 60s linear infinite;
  white-space: nowrap;
  gap: 3rem;
  padding: 0 1rem;
}

.ticker-content:hover { animation-play-state: paused; }

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.ticker-item .symbol { color: var(--text-primary); font-weight: 600; }
.ticker-item .value { color: var(--text-primary); }
.ticker-item .change.up { color: var(--green); }
.ticker-item .change.down { color: var(--red); }

.ticker-loading {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: var(--mono);
}

/* ===== Header ===== */
.header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-group { display: flex; align-items: center; gap: 1.2rem; }

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon { font-size: 1.6rem; }

.logo h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.logo-accent { color: var(--accent); }

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 1.2rem;
}

.header-actions { display: flex; align-items: center; gap: 0.6rem; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.7rem;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.45rem 0.8rem 0.45rem 2.2rem;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  width: 220px;
  transition: all 0.2s;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  width: 280px;
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-box input::placeholder { color: var(--text-muted); }

.btn-refresh, .btn-theme {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}

.btn-refresh:hover, .btn-theme:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-refresh svg, .btn-theme svg { width: 16px; height: 16px; }

.btn-refresh.loading svg { animation: spin 0.8s linear infinite; }

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

.btn-theme .icon-moon { display: none; }
[data-theme="light"] .btn-theme .icon-sun { display: none; }
[data-theme="light"] .btn-theme .icon-moon { display: block; }

/* ===== Filter Bar ===== */
.filter-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-height);
  z-index: 90;
}

.filter-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.filter-group {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.filter-group::-webkit-scrollbar { display: none; }

.filter-btn {
  padding: 0.35rem 0.8rem;
  border: 1px solid transparent;
  background: none;
  border-radius: 20px;
  font-size: 0.78rem;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.filter-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.filter-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--mono);
}

.separator { margin: 0 0.3rem; opacity: 0.4; }

/* ===== Category Tabs ===== */
.category-tabs {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.category-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.category-inner::-webkit-scrollbar { display: none; }

.cat-btn {
  padding: 0.3rem 0.7rem;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.cat-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.cat-btn.active { color: var(--accent); background: var(--accent-dim); }

/* ===== Main Content ===== */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.2rem 1.5rem;
}

/* ===== Featured Section ===== */
.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

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

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.featured-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.featured-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--card-accent, var(--accent));
}

.featured-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.featured-card .card-source {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--card-accent, var(--accent));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
}

.featured-card .card-title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.featured-card .card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.featured-card .card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.card-category {
  background: var(--bg-tertiary);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.68rem;
}

/* ===== News List (Compact) ===== */
.news-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.view-toggle { display: flex; gap: 0.2rem; }

.view-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.view-btn svg { width: 15px; height: 15px; }
.view-btn:hover { color: var(--text-primary); }
.view-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

.news-list { display: flex; flex-direction: column; }

/* Compact View (default) */
.news-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.12s;
}

.news-item:hover {
  background: var(--bg-card-hover);
}

.news-item:last-child { border-bottom: none; }

.news-source {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 140px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.news-source .source-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.news-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.news-title {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.news-item:hover .news-title { color: var(--accent); }

.news-desc {
  font-size: 0.73rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none;
}

.news-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
  text-align: right;
}

.news-time .category-tag {
  display: inline-block;
  background: var(--bg-tertiary);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-size: 0.65rem;
  margin-left: 0.4rem;
}

/* Card View */
.news-list.card-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.6rem;
}

.news-list.card-view .news-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.news-list.card-view .news-item:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.news-list.card-view .news-title {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.news-list.card-view .news-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}

.news-list.card-view .news-source { min-width: unset; }

.news-list.card-view .news-time {
  align-self: flex-end;
  text-align: right;
}

/* ===== Loading & Error ===== */
.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

.error-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.error-icon { font-size: 2rem; }

.btn-retry {
  margin-top: 0.8rem;
  padding: 0.5rem 1.2rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  margin-top: 3rem;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-disclaimer {
  font-size: 0.7rem;
  margin-top: 0.3rem;
  opacity: 0.7;
}

.footer-sources {
  margin-top: 0.6rem;
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--text-muted);
  opacity: 0.6;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  html { font-size: 13px; }
  .tagline { display: none; }
  .search-box input { width: 140px; }
  .search-box input:focus { width: 180px; }
  .filter-inner { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .featured-grid { grid-template-columns: 1fr; }
  .news-item { grid-template-columns: auto 1fr auto; gap: 0.5rem; }
  .news-source { min-width: 90px; font-size: 0.68rem; }
  .news-list.card-view { grid-template-columns: 1fr; }
  .header-inner { padding: 0 1rem; }
  .main-content { padding: 1rem; }
}

@media (max-width: 480px) {
  .news-source { display: none; }
  .news-item { grid-template-columns: 1fr auto; }
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-card-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-title { height: 14px; width: 80%; margin-bottom: 0.4rem; }
.skeleton-desc { height: 10px; width: 60%; }
.skeleton-source { height: 10px; width: 100px; }
