/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f4f4f4;
  color: #333;
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
}
body.dark { background-color: #1a1a2e; color: #e0e0e0; }
a { color: #0066cc; text-decoration: none; }
a:hover { text-decoration: underline; }
body.dark a { color: #f0c040; }

/* === Layout === */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}
#app {
  min-height: 60vh;
}
img { max-width: 100%; height: auto; }
section { scroll-margin-top: 60px; }

/* === Nav === */
nav {
  background-color: #333;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
body.dark nav { background-color: #0f3460; }
.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 15px;
  gap: 6px;
}
nav a {
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.85em;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background-color 0.2s, color 0.2s;
  white-space: nowrap;
}
nav a:hover, nav a.active {
  background-color: rgba(255,255,255,0.15);
  color: #f0c040;
  text-decoration: none;
}
.nav-spacer { flex: 1; }
.hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5em;
  cursor: pointer;
  padding: 6px;
}
.nav-links { display: contents; }
@media (max-width: 768px) {
  .hamburger { display: block; }
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 4px;
    padding-top: 8px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 8px 10px; }
}

/* === Dark toggle === */
.dark-toggle {
  background: none;
  border: 2px solid #fff;
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8em;
  transition: background-color 0.2s;
  white-space: nowrap;
}
.dark-toggle:hover { background-color: rgba(255,255,255,0.15); }

/* === Scroll progress === */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: #f0c040;
  z-index: 200;
  width: 0;
  transition: width 0.1s linear;
}

/* === Back to top === */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #333;
  color: #fff;
  border: none;
  font-size: 1.4em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, background-color 0.3s;
  z-index: 99;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background-color: #555; }
body.dark .back-to-top { background-color: #0f3460; }
body.dark .back-to-top:hover { background-color: #1a4a8a; }

/* === Toast === */
.toast {
  position: fixed;
  bottom: 30px;
  left: 30px;
  background: #333;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9em;
  z-index: 200;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: 350px;
}
.toast.show { opacity: 1; transform: translateY(0); }
body.dark .toast { background: #0f3460; color: #e0e0e0; }

/* === Footer === */
footer {
  background-color: #333;
  color: #aaa;
  text-align: center;
  padding: 20px;
  margin-top: 40px;
  font-size: 0.9em;
}
footer a { color: #f0c040; text-decoration: none; }
body.dark footer { background-color: #0f3460; }
.kbd-hint { font-size: 0.8em; color: #666; margin-top: 8px; }
.kbd-hint kbd {
  background: #555;
  color: #ddd;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.85em;
}
body.dark .kbd-hint { color: #777; }

/* === Focus === */
a:focus-visible, button:focus-visible {
  outline: 2px solid #f0c040;
  outline-offset: 2px;
}

/* === Loading === */
.loading {
  text-align: center;
  padding: 40px;
  color: #888;
}
.loading::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #ccc;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-left: 10px;
}
body.dark .loading::after { border-color: #555; border-top-color: #f0c040; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Loading skeleton === */
.skeleton {
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
body.dark .skeleton {
  background: linear-gradient(90deg, #1e2a4a 25%, #253560 50%, #1e2a4a 75%);
  background-size: 200% 100%;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card {
  height: 120px;
  margin-bottom: 15px;
}

/* === Fade-in === */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* === Hero === */
.hero {
  text-align: center;
  margin-bottom: 30px;
}
.hero img { border-radius: 10px; }
.hero h1 {
  font-size: 1.8em;
  margin: 15px 0 5px;
  color: #222;
}
body.dark .hero h1 { color: #f0c040; }

/* === Category Grid (home page) === */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin: 25px 0;
}
.category-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.category-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  text-decoration: none;
}
body.dark .category-card { background: #16213e; border-color: #0f3460; }
body.dark .category-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.category-card .cat-icon { font-size: 2em; margin-bottom: 8px; }
.category-card .cat-name { font-weight: bold; font-size: 1.1em; }
.category-card .cat-count { font-size: 0.85em; color: #888; margin-top: 4px; }

/* === Article Cards === */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.article-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  transition: box-shadow 0.2s;
  text-align: left;
}
.article-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.08); }
body.dark .article-card { background: #16213e; border-color: #0f3460; }
body.dark .article-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.3); }
.article-card h3 {
  margin: 0 0 6px;
  font-size: 1.05em;
  line-height: 1.3;
}
.article-card h3 a { color: inherit; }
.article-card h3 a:hover { color: #0066cc; text-decoration: underline; }
body.dark .article-card h3 a:hover { color: #f0c040; }
.article-card p {
  margin: 0;
  font-size: 0.9em;
  color: #666;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
body.dark .article-card p { color: #999; }
.article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.article-date {
  font-size: 0.78em;
  color: #999;
}

/* === Source Badge === */
.source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  color: #fff;
  font-size: 0.7em;
  font-weight: bold;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* === Bookmark Button === */
.bookmark-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  padding: 2px 6px;
  opacity: 0.4;
  transition: opacity 0.2s, transform 0.2s;
  float: right;
}
.bookmark-btn:hover { opacity: 0.7; }
.bookmark-btn.saved { opacity: 1; color: #e74c3c; transform: scale(1.1); }

/* === Controls (filters, search, sort) === */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-pills button {
  padding: 5px 14px;
  border: 2px solid #333;
  background: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82em;
  font-weight: bold;
  color: #333;
  transition: all 0.2s;
}
.filter-pills button.active,
.filter-pills button:hover {
  background-color: #333;
  color: #fff;
}
body.dark .filter-pills button { border-color: #f0c040; color: #e0e0e0; }
body.dark .filter-pills button.active,
body.dark .filter-pills button:hover { background-color: #f0c040; color: #1a1a2e; }

.search-input {
  flex: 1;
  min-width: 160px;
  padding: 8px 14px;
  border: 2px solid #ddd;
  border-radius: 20px;
  font-size: 0.9em;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: #f0c040; }
body.dark .search-input { background-color: #16213e; border-color: #0f3460; color: #e0e0e0; }
body.dark .search-input:focus { border-color: #f0c040; }

.sort-pills {
  display: flex;
  gap: 6px;
}
.sort-pills button {
  padding: 4px 12px;
  border: 1px solid #aaa;
  background: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.78em;
  color: #555;
  transition: all 0.2s;
}
.sort-pills button.active { background: #555; color: #fff; border-color: #555; }
body.dark .sort-pills button { border-color: #555; color: #aaa; }
body.dark .sort-pills button.active { background: #f0c040; color: #1a1a2e; border-color: #f0c040; }

.result-count {
  font-size: 0.85em;
  color: #888;
  margin: 5px 0 10px;
}

/* === Page Header === */
.page-header {
  margin-bottom: 20px;
}
.page-header h2 {
  font-size: 1.5em;
  margin: 0 0 8px;
  border-bottom: 2px solid #ddd;
  padding-bottom: 8px;
}
body.dark .page-header h2 { border-bottom-color: #0f3460; }

/* === Article Detail (reader view) === */
.article-detail {
  max-width: 700px;
  margin: 0 auto;
  text-align: left;
}
.article-detail h1 {
  font-size: 1.6em;
  line-height: 1.3;
  margin: 0 0 12px;
}
.article-detail .detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.article-detail .detail-body {
  font-size: 1em;
  line-height: 1.7;
  color: #444;
}
body.dark .article-detail .detail-body { color: #ccc; }
.article-detail .detail-body img { border-radius: 8px; margin: 15px 0; }
.article-detail .detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 25px;
  flex-wrap: wrap;
}
.btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.9em;
  font-weight: bold;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
}
.btn-primary { background: #333; color: #fff; }
.btn-primary:hover { background: #555; color: #fff; text-decoration: none; }
body.dark .btn-primary { background: #f0c040; color: #1a1a2e; }
body.dark .btn-primary:hover { background: #e0b030; }
.btn-secondary { background: #e0e0e0; color: #333; }
.btn-secondary:hover { background: #d0d0d0; text-decoration: none; }
body.dark .btn-secondary { background: #16213e; color: #e0e0e0; }

/* === Video === */
.video-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}
.video-grid > div { width: 400px; }
.video-thumb {
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
}
.video-thumb img {
  width: 100%;
  height: 225px;
  object-fit: cover;
  display: block;
}
.video-thumb .play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: rgba(0,0,0,0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.video-thumb .play-btn::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 12px 0 12px 22px;
  border-color: transparent transparent transparent #fff;
  margin-left: 4px;
}
.video-thumb:hover .play-btn { background: rgba(0,0,0,0.9); }
.video-grid h3 { font-size: 1em; margin: 8px 0; }

/* === Load More === */
.load-more {
  text-align: center;
  margin: 20px 0;
}
.load-more button {
  padding: 10px 30px;
  border: 2px solid #333;
  background: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: bold;
  color: #333;
  transition: all 0.2s;
}
.load-more button:hover { background: #333; color: #fff; }
body.dark .load-more button { border-color: #f0c040; color: #e0e0e0; }
body.dark .load-more button:hover { background: #f0c040; color: #1a1a2e; }

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}
.empty-state .empty-icon { font-size: 3em; margin-bottom: 15px; }
