:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --accent: #0066ff;
  --border: #e5e5e5;
  --card-bg: #f7f7f7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #f2f2f2;
    --muted: #999999;
    --accent: #4d94ff;
    --border: #222222;
    --card-bg: #151515;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}

a { color: var(--accent); }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.site-brand {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--fg);
}

.site-brand.active {
  color: var(--accent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-link {
  text-decoration: none;
  color: var(--fg);
  font-size: 0.95rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--accent);
}

.nav-link.active {
  color: var(--accent);
  font-weight: 600;
}

.nav-link-external {
  background: #d9d9d9;
  color: #111111;
  border: 1px solid #bfbfbf;
  border-radius: 8px;
  padding: 0.35rem 0.85rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-link-external:hover {
  background: #cccccc;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

/* ---------- Main / typography ---------- */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

h1 { font-size: 2.25rem; font-weight: 800; line-height: 1.2; margin-top: 0.5rem; }
h2 { font-size: 1.6rem; font-weight: 700; line-height: 1.3; }

.full-post h2,
.post-content .article-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.25;
  margin-top: 0;
  margin-bottom: 0.25rem;
}

.full-post h2 a,
.post-content .article-title a {
  color: var(--fg);
  text-decoration: none;
}

.full-post h2 a:hover,
.post-content .article-title a:hover {
  color: var(--accent);
}

.post-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.post-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.75rem 0;
}

main img,
.post-content img,
.full-post img,
article img {
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
  margin: 1rem auto;
  border-radius: 8px;
}

main video,
.post-content video,
.full-post video,
article video {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  display: block;
  margin: 0;
  border-radius: 8px;
}

/* ---------- Custom video play/pause overlay ---------- */
.video-wrap {
  position: relative;
  margin: 1rem auto;
}

.video-overlay-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.video-overlay-btn.visible {
  opacity: 1;
}

.video-caption {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.75rem 0 1.5rem;
}

/* ---------- Blog listing (card grid) ---------- */
.post-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.post-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card-bg);
  transition: transform 0.15s ease;
}

.post-card:hover {
  transform: translateY(-2px);
}

.post-card-link {
  text-decoration: none;
  color: var(--fg);
  display: block;
}

.post-card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  margin: 0;
  border-radius: 0;
}

.post-card-title {
  margin: 0.75rem 1rem 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.post-card-link:hover .post-card-title {
  color: var(--accent);
}

.post-card .post-meta {
  margin: 0.25rem 1rem 0;
}

.post-card-preview {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0.5rem 1rem 0.5rem;
  line-height: 1.5;
}

.read-more {
  margin: 0 1rem 1rem;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}

/* ---------- Archive list on homepage ---------- */
.archive-posts {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border);
}

.compact-post-list {
  list-style: none;
  padding-left: 0;
}

.compact-post-list li {
  margin-bottom: 0.5rem;
}

.compact-post-list time {
  color: var(--muted);
  font-size: 0.9em;
}

.blog-archive-link {
  margin-top: 2rem;
  padding: 1rem 0;
  text-align: center;
}

.blog-archive-link a {
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
}

.blog-archive-link a:hover {
  text-decoration: underline;
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.5rem 2rem;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
  }

  .header-left {
    gap: 0.75rem;
  }

  .header-right {
    width: 100%;
    justify-content: flex-start;
  }

  main {
    padding: 1.25rem;
  }

  h1 { font-size: 1.8rem; }
  .full-post h2,
  .post-content .article-title { font-size: 1.6rem; }

  .post-list {
    grid-template-columns: 1fr;
  }
}
