:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --accent: #f59e0b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 6px 10px -6px rgba(15, 23, 42, 0.06);
  --radius: 14px;
}

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

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  background: #0f172a;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-lg);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}

.brand-text {
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.category-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.category-nav .cat-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.category-nav .cat-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.category-nav .cat-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------- Hero ---------- */
.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 32px 0 8px;
}

.hero h1 {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.hero p {
  color: var(--muted);
  margin-top: 6px;
  font-size: 15px;
}

.refresh-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.last-updated {
  font-size: 13px;
  color: var(--muted);
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.refresh-btn:hover { background: var(--primary-dark); }
.refresh-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Status ---------- */
.status {
  margin: 20px 0;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: #fff;
}

.status.error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.status.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------- News grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
  padding: 22px 0 40px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s, box-shadow 0.18s;
  border: 1px solid var(--border);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
}

.card-img-placeholder {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  color: #94a3b8;
  font-size: 40px;
  font-weight: 800;
}

.card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
}

.source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.source-name { font-weight: 700; color: var(--primary); }

.card-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc {
  font-size: 14px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

.read-more { color: var(--primary); font-weight: 600; }

/* ---------- Empty / skeleton ---------- */
.empty { padding: 60px 0; text-align: center; color: var(--muted); }

.setup-card {
  grid-column: 1 / -1;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  max-width: 720px;
  margin: 20px auto;
}

.setup-card h3 { font-size: 20px; font-weight: 800; margin-bottom: 10px; }
.setup-card p { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.setup-card ol { margin: 0 0 14px 20px; color: var(--text); font-size: 14px; }
.setup-card ol li { margin-bottom: 8px; line-height: 1.5; }
.setup-card code {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 13px;
  font-family: "SFMono-Regular", Consolas, monospace;
}
.setup-card a { color: var(--primary); }
.setup-note { font-weight: 600; color: var(--primary); }

.skeleton {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.skeleton .shimmer {
  width: 100%;
  height: 180px;
  background: linear-gradient(100deg, #e2e8f0 40%, #f1f5f9 50%, #e2e8f0 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton .s-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.skeleton .s-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(100deg, #e2e8f0 40%, #f1f5f9 50%, #e2e8f0 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.skeleton .s-line.w70 { width: 70%; }
.skeleton .s-line.w100 { width: 100%; }
.skeleton .s-line.w40 { width: 40%; }

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

/* ---------- Footer ---------- */
.site-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 24px 0;
  font-size: 14px;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nav-toggle { display: flex; }

  .category-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    padding: 8px 0;
  }

  .category-nav.open { display: flex; }

  .category-nav .cat-btn {
    text-align: left;
    border-radius: 8px;
    border: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .hero { align-items: flex-start; flex-direction: column; }
}
