:root, [data-theme="blue"] {
  --primary: #1a73e8;
  --primary-hover: #1256b3;
  --primary-light: #eef3fc;
  --bg: #f7f9fc;
  --card-bg: #ffffff;
  --text: #333333;
  --text-secondary: #777777;
  --text-muted: #999999;
  --border: #e8e8e8;
  --footer-bg: #222222;
  --footer-text: #aaaaaa;
  --tag-bg: #eef3fc;
  --tag-color: #1a73e8;
  --nav-bg: #ffffff;
  --nav-shadow: rgba(0,0,0,0.06);
  --code-bg: #eef3fc;
  --code-color: #d63384;
  --blockquote-bg: #f8faff;
  --table-th-bg: #f5f7fa;
}

[data-theme="green"] {
  --primary: #2d8a56;
  --primary-hover: #236e45;
  --primary-light: #e6f4ea;
  --bg: #f6f9f7;
  --card-bg: #ffffff;
  --text: #2d3330;
  --text-secondary: #6b7a70;
  --text-muted: #8a9a8e;
  --border: #dce5de;
  --footer-bg: #1a2e22;
  --footer-text: #8a9a8e;
  --tag-bg: #e6f4ea;
  --tag-color: #2d8a56;
  --nav-bg: #ffffff;
  --nav-shadow: rgba(0,0,0,0.06);
  --code-bg: #e6f4ea;
  --code-color: #2d8a56;
  --blockquote-bg: #f6fdf7;
  --table-th-bg: #f0f7f2;
}

[data-theme="purple"] {
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-light: #f3eeff;
  --bg: #faf8ff;
  --card-bg: #ffffff;
  --text: #3a2e4a;
  --text-secondary: #7a6e8a;
  --text-muted: #9a8eaa;
  --border: #e5ddf5;
  --footer-bg: #2d1b4a;
  --footer-text: #9a8eaa;
  --tag-bg: #f3eeff;
  --tag-color: #7c3aed;
  --nav-bg: #ffffff;
  --nav-shadow: rgba(0,0,0,0.06);
  --code-bg: #f3eeff;
  --code-color: #7c3aed;
  --blockquote-bg: #fbf8ff;
  --table-th-bg: #f7f2ff;
}

[data-theme="warm"] {
  --primary: #d97706;
  --primary-hover: #b45309;
  --primary-light: #fef3c7;
  --bg: #fefcf5;
  --card-bg: #ffffff;
  --text: #3d3522;
  --text-secondary: #7a7055;
  --text-muted: #9a9070;
  --border: #ede5d0;
  --footer-bg: #2d2410;
  --footer-text: #9a9070;
  --tag-bg: #fef3c7;
  --tag-color: #d97706;
  --nav-bg: #ffffff;
  --nav-shadow: rgba(0,0,0,0.06);
  --code-bg: #fef8e6;
  --code-color: #d97706;
  --blockquote-bg: #fffef8;
  --table-th-bg: #fdf6e8;
}

[data-theme="dark"] {
  --primary: #60a5fa;
  --primary-hover: #93bbfd;
  --primary-light: #1e3a5f;
  --bg: #1a1a2e;
  --card-bg: #252540;
  --text: #d4d4d8;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border: #333350;
  --footer-bg: #0f0f1a;
  --footer-text: #6b7280;
  --tag-bg: #1e3a5f;
  --tag-color: #60a5fa;
  --nav-bg: #252540;
  --nav-shadow: rgba(0,0,0,0.3);
  --code-bg: #2a2a45;
  --code-color: #93bbfd;
  --blockquote-bg: #222240;
  --table-th-bg: #2a2a45;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: var(--primary);
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-hover);
}

nav {
  background: var(--nav-bg);
  box-shadow: 0 2px 8px var(--nav-shadow);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text);
}

.logo:hover {
  color: var(--primary);
}

.nav-links a {
  margin-left: 1.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
}

.theme-toggle {
  position: relative;
  margin-left: 8px;
}

.theme-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: transform 0.2s;
}

.theme-btn:hover {
  transform: rotate(30deg);
}

.theme-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.14);
  padding: 6px;
  z-index: 200;
  min-width: 110px;
}

.theme-toggle.open .theme-dropdown {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.15s;
}

.theme-option::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.theme-option:hover {
  background: var(--tag-bg);
}

.theme-option[data-theme="blue"]::before { background: #1a73e8; }
.theme-option[data-theme="green"]::before { background: #2d8a56; }
.theme-option[data-theme="purple"]::before { background: #7c3aed; }
.theme-option[data-theme="warm"]::before { background: #d97706; }
.theme-option[data-theme="dark"]::before { background: #555; }

.container {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  gap: 2rem;
  flex: 1;
  width: 100%;
}

main {
  flex: 1;
  min-width: 0;
}

aside {
  width: 300px;
  flex-shrink: 0;
}

article {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

article:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

article h2 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

article h2 a {
  color: var(--text);
}

article h2 a:hover {
  color: var(--primary);
}

.post-title {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.meta {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.excerpt {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.read-more {
  font-weight: 500;
}

.article-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.article-card .meta {
  text-align: center;
}

.article-card .post-title {
  text-align: center;
  font-size: 1.8rem;
}

.post-content {
  font-size: 16px;
  line-height: 1.9;
  color: var(--text);
}

.post-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  color: var(--text);
}

.post-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 24px 0 10px;
}

.post-content p {
  margin-bottom: 16px;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 20px auto;
}

.post-content figure {
  margin: 20px 0;
  text-align: center;
}

.post-content figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.post-content a {
  word-break: break-all;
}

.post-content ul,
.post-content ol {
  margin: 12px 0 16px 24px;
}

.post-content li {
  margin-bottom: 6px;
}

.post-content blockquote {
  border-left: 3px solid var(--primary);
  padding: 12px 20px;
  margin: 20px 0;
  background: var(--blockquote-bg);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
}

.post-content code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Consolas, monospace;
  color: var(--code-color);
}

.post-content pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 20px 24px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
}

.post-content table th,
.post-content table td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}

.post-content table th {
  background: var(--table-th-bg);
  font-weight: 600;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.btn-green,
.btn-orange {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  color: #fff !important;
  transition: opacity 0.2s;
  margin: 4px 4px 4px 0;
}

.btn-green {
  background: #2d8a56;
}

.btn-green:hover {
  opacity: 0.85;
}

.btn-orange {
  background: #e8903a;
}

.btn-orange:hover {
  opacity: 0.85;
}

.widget {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.3rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.widget h3 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  color: var(--text);
}

.widget ul {
  list-style: none;
}

.widget ul li {
  margin-bottom: 0.5rem;
}

.widget ul li a {
  color: var(--text-secondary);
}

.widget ul li a:hover {
  color: var(--primary);
}

.tag-cloud a {
  display: inline-block;
  background: var(--tag-bg);
  padding: 0.2rem 0.8rem;
  border-radius: 20px;
  margin: 0.2rem;
  font-size: 0.9rem;
  color: var(--tag-color);
}

.tag-cloud a:hover {
  opacity: 0.8;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  gap: 16px;
}

.post-nav a {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.post-nav a:hover {
  color: var(--primary);
}

footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  text-align: center;
  padding: 2rem 1rem;
  margin-top: 3rem;
  font-size: 0.9rem;
}

footer a {
  color: #ccc;
}

footer a:hover {
  color: #fff;
}

.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.back-to-top:hover {
  opacity: 0.85;
  transform: translateY(-2px);
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }
  aside {
    width: 100%;
  }
  .nav-inner {
    flex-direction: column;
    gap: 0.5rem;
  }
  .nav-links a {
    margin-left: 0.8rem;
    margin-right: 0.8rem;
  }
  .article-card {
    padding: 1.2rem;
  }
  .article-card .post-title {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  article {
    padding: 1rem;
  }
  article h2 {
    font-size: 1.3rem;
  }
}
