:root {
  --bg-color: #ffffff;
  --text-color: #24292f;
  --muted-color: #57606a;
  --link-color: #0969da;
  --border-color: #d0d7de;
  --card-bg: #f6f8fa;
  --max-width: 720px;
  --header-height: 60px;
}

[data-theme="dark"] {
  --bg-color: #0d1117;
  --text-color: #c9d1d9;
  --muted-color: #8b949e;
  --link-color: #58a6ff;
  --border-color: #30363d;
  --card-bg: #161b22;
}

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

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--bg-color);
  line-height: 1.7;
  transition: background-color 0.3s, color 0.3s;
}

a { color: var(--link-color); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-width: 0;
}

.site-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-color);
  white-space: nowrap;
}

.site-title:hover { color: var(--link-color); text-decoration: none; }

.site-subtitle {
  font-size: 0.8rem;
  color: var(--muted-color);
  white-space: nowrap;
}

.header-nav {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
}

.header-nav a {
  color: var(--muted-color);
  font-weight: 500;
  white-space: nowrap;
}

.header-nav a:hover {
  color: var(--link-color);
  text-decoration: none;
}

.theme-switch-wrapper {
  flex-shrink: 0;
}

.theme-switch {
  display: inline-block;
  height: 22px;
  width: 40px;
  position: relative;
}

.theme-switch input { display: none; }

.slider {
  background-color: #ccc;
  border-radius: 22px;
  position: absolute;
  inset: 0;
  cursor: pointer;
  transition: .3s;
}

.slider:before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  border-radius: 50%;
  transition: .3s;
}

input:checked + .slider { background-color: var(--link-color); }
input:checked + .slider:before { transform: translateX(18px); }

/* Content */
#content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* Post list on homepage */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border-color);
}

.post-list li:first-child {
  padding-top: 0;
}

.post-list .post-date {
  font-size: 0.8rem;
  color: var(--muted-color);
  display: inline-block;
  min-width: 5.5rem;
  flex-shrink: 0;
}

.post-list .post-link {
  font-weight: 500;
  color: var(--text-color);
}

.post-list .post-link:hover {
  color: var(--link-color);
  text-decoration: none;
}

.post-list li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}



/* Single post */
h1.title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  border: none;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--muted-color);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
}

.post-meta .sep {
  margin: 0 0.35rem;
  color: var(--border-color);
}

.tag {
  display: inline-block;
  background: var(--card-bg);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--muted-color);
}

a.tag:hover {
  color: var(--link-color);
  text-decoration: none;
  background: var(--border-color);
}

.post-meta .sep {
  margin: 0 0.15rem;
  color: var(--border-color);
}

.post-meta .tag {
  margin-left: 0.3rem;
}

.tag.draft {
  background: #f0c000;
  color: #000;
  font-weight: 700;
  letter-spacing: 0.03em;
}

#content {
  line-height: 1.8;
}

#content h2 {
  font-size: 1.4rem;
  margin-top: 2.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-color);
}

#content h3 {
  font-size: 1.15rem;
  margin-top: 2rem;
}

#content h4 {
  font-size: 1rem;
  margin-top: 1.5rem;
  color: var(--muted-color);
}

#content p, #content li {
  line-height: 1.8;
}

#content figure {
  margin: 2rem auto;
  max-width: 70%;
  text-align: center;
}

#content figure img {
  max-width: 100%;
  height: auto;
  max-height: 50vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: zoom-in;
}

#content figure figcaption {
  font-size: 0.8rem;
  color: var(--muted-color);
  margin-top: 0.5rem;
  text-align: center;
  font-style: italic;
  max-width: 90%;
}

#content figure figcaption .figure-number {
  font-weight: 600;
  font-style: normal;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox-img {
  max-width: 95vw;
  max-height: 80vh;
  border-radius: 4px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.5);
  cursor: default;
}

.lightbox-caption {
  color: #ccc;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  text-align: center;
  font-style: italic;
  max-width: 80vw;
}

.lightbox-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.lightbox-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.2s;
  padding: 0;
}

.lightbox-btn:hover {
  background: rgba(255,255,255,0.3);
}

.lightbox-dots {
  display: flex;
  gap: 8px;
}

.lightbox-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: background 0.2s;
}

.lightbox-dot.active {
  background: #fff;
}

.lightbox-dot:hover {
  background: rgba(255,255,255,0.6);
}

/* Carousel */
.carousel {
  margin: 2rem auto;
  max-width: 70%;
}

.carousel-slides {
  position: relative;
}

#content .carousel-slide {
  display: none;
  margin: 0;
  max-width: 100%;
}

#content .carousel-slide.active {
  display: block;
}

#content .carousel-slide img {
  max-width: 100%;
  height: auto;
  max-height: 50vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: zoom-in;
}

#content .carousel-slide figcaption {
  font-size: 0.8rem;
  color: var(--muted-color);
  margin-top: 0.5rem;
  text-align: center;
  font-style: italic;
}

#content .carousel-slide figcaption .figure-number {
  font-weight: 600;
  font-style: normal;
}

.carousel-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.carousel-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  transition: background 0.2s;
  padding: 0;
}

.carousel-btn:hover {
  background: var(--border-color);
}

.carousel-dots {
  display: flex;
  gap: 6px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
}

.carousel-dot.active {
  background: var(--link-color);
}

.carousel-dot:hover {
  background: var(--muted-color);
}

/* Reading time */
.reading-time {
  font-size: 0.75rem;
  color: var(--muted-color);
}

/* Table of contents */
.toc {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  font-size: 0.85rem;
}

.toc strong {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-color);
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  padding: 0.15rem 0;
}

.toc a {
  color: var(--link-color);
}

#content blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 1.2rem;
  border-left: 3px solid var(--link-color);
  color: var(--muted-color);
  background: var(--card-bg);
  border-radius: 0 6px 6px 0;
}

/* Code */
pre.src {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}

code {
  font-size: 0.85em;
  background: var(--card-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

pre.src code { background: none; padding: 0; }

/* Footer */
.blog-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted-color);
}

/* Categories page */
.category-section {
  margin-bottom: 2rem;
}

.category-section h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--text-color);
  border: none;
  padding: 0;
}

.category-post {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: 0.4rem 0;
}

.category-post .post-date {
  font-size: 0.8rem;
  color: var(--muted-color);
  min-width: 5.5rem;
}

/* Responsive */
@media (max-width: 600px) {
  .header-inner {
    padding: 0 1rem;
    gap: 0.5rem;
  }

  .site-subtitle { display: none; }

  .header-nav { gap: 0.75rem; font-size: 0.8rem; }

  h1.title { font-size: 1.6rem; }

  .post-list li {
    flex-direction: column;
    gap: 0.2rem;
  }

  .post-list .post-date {
    min-width: 0;
    font-size: 0.75rem;
  }

  #content { padding: 1.5rem 1rem 3rem; }
}
