:root,
[data-theme="light"] {
  --bg: #ffffff;
  --bg-secondary: #f6f8fa;
  --text: #1a1a2e;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --heading: #0d1117;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --border: #e2e8f0;
  --code-bg: #f6f8fa;
  --inline-code-bg: #eff1f3;
  --tag-bg: #e8eef5;
  --tag-text: #2563eb;
  --header-bg: rgba(255, 255, 255, 0.85);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --text: #e6edf3;
  --text-secondary: #b1bac4;
  --text-muted: #8b949e;
  --heading: #f0f6fc;
  --link: #58a6ff;
  --link-hover: #79c0ff;
  --border: #30363d;
  --code-bg: #161b22;
  --inline-code-bg: #272d37;
  --tag-bg: #1c2738;
  --tag-text: #58a6ff;
  --header-bg: rgba(13, 17, 23, 0.85);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: color 0.2s ease, background-color 0.2s ease;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--link-hover);
}

img {
  max-width: 100%;
  height: auto;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

main.container {
  flex: 1;
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

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

.site-logo:hover {
  color: var(--link);
}

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

.site-nav a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--link);
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.theme-toggle:hover {
  color: var(--link);
}

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

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

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

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

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

.post-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.2s ease;
}

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

.post-item-title {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

.post-item-title a {
  color: var(--heading);
}

.post-item-title a:hover {
  color: var(--link);
}

.post-item-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.35rem;
}

.post-item-excerpt {
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.post-header {
  margin-bottom: 2rem;
}

.post-title {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--heading);
}

.post-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.post-categories a {
  color: var(--link);
  font-weight: 500;
}

.post-tags {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--tag-bg);
  color: var(--tag-text);
  transition: background 0.2s ease;
}

.post-content {
  line-height: 1.8;
}

.post-content h2 {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.post-content h3 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--heading);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.post-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--heading);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.post-content p {
  margin-bottom: 1.5rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.35rem;
}

.post-content blockquote {
  border-left: 3px solid var(--link);
  padding: 0.5rem 1rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--bg-secondary);
  border-radius: 0 4px 4px 0;
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

.post-content img {
  border-radius: 8px;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.post-content table th,
.post-content table td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
}

.post-content table th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.post-content table tr:nth-child(even) {
  background: var(--bg-secondary);
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.post-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content a:hover {
  text-decoration-color: var(--link-hover);
}

.post-content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  font-size: 0.875em;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  background: var(--inline-code-bg);
  transition: background 0.2s ease;
}

.post-content pre {
  padding: 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  background: var(--code-bg);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.post-content pre code {
  padding: 0;
  border-radius: 0;
  background: none;
  font-size: inherit;
}

.highlight {
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.highlight pre {
  margin-bottom: 0;
}

.toc {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 2rem;
  background: var(--bg-secondary);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.toc h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--heading);
}

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

.toc-entry {
  margin-bottom: 0.25rem;
}

.toc-h3 {
  padding-left: 1.25rem;
}

.toc-h4 {
  padding-left: 2.5rem;
}

.toc-entry a {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: none;
}

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

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

.post-nav-prev,
.post-nav-next {
  max-width: 45%;
  text-decoration: none;
}

.post-nav-prev span,
.post-nav-next span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-nav-prev strong,
.post-nav-next strong {
  display: block;
  margin-top: 0.25rem;
  color: var(--heading);
  font-weight: 600;
  transition: color 0.2s ease;
}

.post-nav-prev:hover strong,
.post-nav-next:hover strong {
  color: var(--link);
}

.post-nav-next {
  text-align: right;
  margin-left: auto;
}

.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--heading);
}

.page-content {
  line-height: 1.8;
}

.page-content h2 {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.page-content h3 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--heading);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.page-content p {
  margin-bottom: 1.5rem;
}

.page-content ul,
.page-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.page-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer {
  text-align: center;
  padding: 2rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.category-group,
.tag-group {
  margin-bottom: 2.5rem;
}

.category-group h2,
.tag-group h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--heading);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.category-posts,
.tag-posts {
  list-style: none;
  padding: 0;
}

.category-posts li,
.tag-posts li {
  padding: 0.5rem 0;
}

.category-posts li a,
.tag-posts li a {
  color: var(--heading);
  font-weight: 500;
}

.category-posts li a:hover,
.tag-posts li a:hover {
  color: var(--link);
}

.category-posts li time,
.tag-posts li time {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

.search-container {
  margin-bottom: 2rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.search-input:focus {
  border-color: var(--link);
}

.search-results {
  margin-top: 1rem;
}

.search-result-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.search-result-item h3 {
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
}

.search-result-item p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.comments h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: var(--heading);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin: 2.5rem 0;
}

.pagination a,
.pagination span {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
}

.pagination a {
  color: var(--link);
  border: 1px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.pagination a:hover {
  background: var(--bg-secondary);
  border-color: var(--link);
}

.pagination .current {
  background: var(--link);
  color: #fff;
  border: 1px solid var(--link);
}

[data-theme="light"] .highlight .c,
[data-theme="light"] .highlight .c1,
[data-theme="light"] .highlight .cm,
[data-theme="light"] .highlight .cs,
[data-theme="light"] .highlight .cp {
  color: #6a737d;
  font-style: italic;
}

[data-theme="light"] .highlight .k,
[data-theme="light"] .highlight .kc,
[data-theme="light"] .highlight .kd,
[data-theme="light"] .highlight .kn,
[data-theme="light"] .highlight .kp,
[data-theme="light"] .highlight .kr,
[data-theme="light"] .highlight .kt {
  color: #d73a49;
  font-weight: 600;
}

[data-theme="light"] .highlight .s,
[data-theme="light"] .highlight .s1,
[data-theme="light"] .highlight .s2,
[data-theme="light"] .highlight .sb,
[data-theme="light"] .highlight .sc,
[data-theme="light"] .highlight .sd,
[data-theme="light"] .highlight .se,
[data-theme="light"] .highlight .sh,
[data-theme="light"] .highlight .si,
[data-theme="light"] .highlight .sx,
[data-theme="light"] .highlight .sr {
  color: #032f62;
}

[data-theme="light"] .highlight .mi,
[data-theme="light"] .highlight .mf,
[data-theme="light"] .highlight .mh,
[data-theme="light"] .highlight .mo,
[data-theme="light"] .highlight .il {
  color: #005cc5;
}

[data-theme="light"] .highlight .nf,
[data-theme="light"] .highlight .fm {
  color: #6f42c1;
}

[data-theme="light"] .highlight .nc,
[data-theme="light"] .highlight .nn {
  color: #6f42c1;
  font-weight: 600;
}

[data-theme="light"] .highlight .na {
  color: #005cc5;
}

[data-theme="light"] .highlight .nb {
  color: #005cc5;
}

[data-theme="light"] .highlight .o,
[data-theme="light"] .highlight .ow {
  color: #d73a49;
}

[data-theme="light"] .highlight .p {
  color: #24292e;
}

[data-theme="light"] .highlight .nl {
  color: #005cc5;
}

[data-theme="light"] .highlight .ni {
  color: #24292e;
  font-weight: 600;
}

[data-theme="light"] .highlight .ne {
  color: #d73a49;
  font-weight: 600;
}

[data-theme="light"] .highlight .nv,
[data-theme="light"] .highlight .vi,
[data-theme="light"] .highlight .vc,
[data-theme="light"] .highlight .vg,
[data-theme="light"] .highlight .vs {
  color: #e36209;
}

[data-theme="light"] .highlight .nt {
  color: #22863a;
}

[data-theme="light"] .highlight .err {
  color: #cb2431;
  background-color: #ffeef0;
}

[data-theme="dark"] .highlight .c,
[data-theme="dark"] .highlight .c1,
[data-theme="dark"] .highlight .cm,
[data-theme="dark"] .highlight .cs,
[data-theme="dark"] .highlight .cp {
  color: #8b949e;
  font-style: italic;
}

[data-theme="dark"] .highlight .k,
[data-theme="dark"] .highlight .kc,
[data-theme="dark"] .highlight .kd,
[data-theme="dark"] .highlight .kn,
[data-theme="dark"] .highlight .kp,
[data-theme="dark"] .highlight .kr,
[data-theme="dark"] .highlight .kt {
  color: #ff7b72;
  font-weight: 600;
}

[data-theme="dark"] .highlight .s,
[data-theme="dark"] .highlight .s1,
[data-theme="dark"] .highlight .s2,
[data-theme="dark"] .highlight .sb,
[data-theme="dark"] .highlight .sc,
[data-theme="dark"] .highlight .sd,
[data-theme="dark"] .highlight .se,
[data-theme="dark"] .highlight .sh,
[data-theme="dark"] .highlight .si,
[data-theme="dark"] .highlight .sx,
[data-theme="dark"] .highlight .sr {
  color: #a5d6ff;
}

[data-theme="dark"] .highlight .mi,
[data-theme="dark"] .highlight .mf,
[data-theme="dark"] .highlight .mh,
[data-theme="dark"] .highlight .mo,
[data-theme="dark"] .highlight .il {
  color: #79c0ff;
}

[data-theme="dark"] .highlight .nf,
[data-theme="dark"] .highlight .fm {
  color: #d2a8ff;
}

[data-theme="dark"] .highlight .nc,
[data-theme="dark"] .highlight .nn {
  color: #d2a8ff;
  font-weight: 600;
}

[data-theme="dark"] .highlight .na {
  color: #79c0ff;
}

[data-theme="dark"] .highlight .nb {
  color: #79c0ff;
}

[data-theme="dark"] .highlight .o,
[data-theme="dark"] .highlight .ow {
  color: #ff7b72;
}

[data-theme="dark"] .highlight .p {
  color: #e6edf3;
}

[data-theme="dark"] .highlight .nl {
  color: #79c0ff;
}

[data-theme="dark"] .highlight .ni {
  color: #e6edf3;
  font-weight: 600;
}

[data-theme="dark"] .highlight .ne {
  color: #ff7b72;
  font-weight: 600;
}

[data-theme="dark"] .highlight .nv,
[data-theme="dark"] .highlight .vi,
[data-theme="dark"] .highlight .vc,
[data-theme="dark"] .highlight .vg,
[data-theme="dark"] .highlight .vs {
  color: #ffa657;
}

[data-theme="dark"] .highlight .nt {
  color: #7ee787;
}

[data-theme="dark"] .highlight .err {
  color: #f85149;
  background-color: rgba(248, 81, 73, 0.1);
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem 1.5rem;
    gap: 0.75rem;
    box-shadow: var(--shadow);
  }

  body.menu-open .site-nav {
    display: flex;
  }

  body.menu-open .menu-toggle span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  body.menu-open .menu-toggle span:nth-child(2) {
    opacity: 0;
  }

  body.menu-open .menu-toggle span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }

  .post-title {
    font-size: 1.75rem;
  }

  .post-nav {
    flex-direction: column;
  }

  .post-nav-prev,
  .post-nav-next {
    max-width: 100%;
  }

  .post-nav-next {
    text-align: left;
  }
}
