:root {
  --bg: #fdf6f0;
  --card-bg: #fffaf5;
  --text: #3d2a1e;
  --heading: #4a3020;
  --muted: #8b6b50;
  --accent: #b8956a;
  --link: #7a4020;
  --border: #e0c8b0;
  --shadow: 0 2px 12px rgba(100, 60, 30, 0.1);
  --radius: 12px;
  --max-w: 720px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }

body {
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.85;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}

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

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 20px; }

.site-header { padding: 40px 0 30px; text-align: center; border-bottom: 1px solid var(--border); }
.site-title { font-size: 1.75rem; color: var(--heading); font-weight: normal; letter-spacing: 2px; }
.site-subtitle { font-size: 0.875rem; color: var(--muted); margin-top: 8px; }

.nav { display: flex; justify-content: center; gap: 28px; margin-top: 18px; flex-wrap: wrap; }
.nav a { font-size: 0.875rem; color: var(--muted); transition: color 0.2s; letter-spacing: 1px; }
.nav a:hover { color: var(--link); text-decoration: none; }

.toolbar { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 14px; font-size: 0.8125rem; color: var(--muted); }
.toolbar-btn { width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); color: var(--text); cursor: pointer; font-size: 0.9375rem; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.toolbar-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.toolbar-label { font-size: 0.75rem; }
.toolbar-size { font-size: 0.75rem; min-width: 36px; text-align: center; }
.toolbar-divider { margin: 0 8px; color: var(--border); }

.weather-bar { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 20px; margin: 24px 0; display: flex; align-items: center; gap: 16px; font-size: 0.875rem; color: var(--muted); flex-wrap: wrap; }
.weather-bar .status { font-style: italic; color: var(--heading); flex: 1; }

.post-list { margin: 32px 0; }
.post-item { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; transition: box-shadow 0.2s; }
.post-item:hover { box-shadow: var(--shadow); }
.post-item h2 { font-size: 1.25rem; font-weight: normal; margin-bottom: 6px; }
.post-item h2 a { color: var(--heading); }
.post-meta { font-size: 0.8125rem; color: var(--muted); margin-bottom: 10px; }
.post-summary { font-size: 0.9375rem; color: var(--text); line-height: 1.7; }
.post-tags { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

.tag { display: inline-block; padding: 2px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; font-size: 0.75rem; color: var(--muted); transition: all 0.2s; }
.tag:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }

.article { padding: 32px 0; }
.article h1 { font-size: 1.75rem; color: var(--heading); font-weight: normal; margin-bottom: 8px; line-height: 1.4; }
.article h2 { font-size: 1.375rem; color: var(--heading); margin: 28px 0 12px; font-weight: normal; }
.article h3 { font-size: 1.125rem; color: var(--heading); margin: 22px 0 10px; font-weight: normal; }
.article p { margin-bottom: 16px; font-size: 1rem; }
.article ul, .article ol { margin: 12px 0 12px 24px; font-size: 1rem; }
.article li { margin-bottom: 6px; }
.article blockquote { border-left: 3px solid var(--accent); padding: 8px 16px; margin: 16px 0; background: var(--card-bg); border-radius: 0 var(--radius) var(--radius) 0; color: var(--muted); font-style: italic; font-size: 0.9375rem; }
.article code { background: #f0e6da; padding: 2px 6px; border-radius: 4px; font-family: "Fira Code", Consolas, monospace; font-size: 0.875rem; }
.article pre { background: #2d2420; color: #f0e6da; padding: 16px 20px; border-radius: var(--radius); overflow-x: auto; margin: 16px 0; font-size: 0.875rem; line-height: 1.6; }
.article pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.article img { max-width: 100%; border-radius: var(--radius); margin: 16px 0; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

.article table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.875rem; }
.article th, .article td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.article th { background: var(--accent); color: #fff; font-weight: normal; }
.article tr:nth-child(even) td { background: var(--card-bg); }

.article details { margin: 12px 0; padding: 12px 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); }
.article summary { cursor: pointer; color: var(--link); font-weight: bold; }

.comments { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--border); }
.comments h3 { font-size: 1.125rem; color: var(--heading); font-weight: normal; margin-bottom: 20px; }
.comment-form { margin-bottom: 28px; }
.comment-form input, .comment-form textarea { width: 100%; padding: 10px 14px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-family: inherit; font-size: 0.875rem; color: var(--text); outline: none; transition: border-color 0.2s; }
.comment-form input:focus, .comment-form textarea:focus { border-color: var(--accent); }
.comment-form textarea { min-height: 80px; resize: vertical; }
.comment-form button { padding: 8px 24px; background: var(--accent); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 0.875rem; transition: opacity 0.2s; }
.comment-form button:hover { opacity: 0.85; }
.comment-item { padding: 16px 0; border-bottom: 1px solid var(--border); }
.comment-author { font-size: 0.875rem; font-weight: bold; color: var(--heading); margin-bottom: 4px; }
.comment-date { font-size: 0.75rem; color: var(--muted); margin-bottom: 6px; }
.comment-content { font-size: 0.9375rem; color: var(--text); line-height: 1.7; }

.about-section { padding: 32px 0; }
.about-section h2 { font-size: 1.375rem; color: var(--heading); font-weight: normal; margin-bottom: 16px; }
.about-section p { margin-bottom: 14px; font-size: 1rem; line-height: 1.85; }

.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 32px 0; }
.link-card { display: flex; align-items: center; gap: 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; transition: box-shadow 0.2s; }
.link-card:hover { box-shadow: var(--shadow); text-decoration: none; }
.link-card img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.link-card h3 { font-size: 0.9375rem; color: var(--heading); font-weight: normal; }
.link-card p { font-size: 0.8125rem; color: var(--muted); margin-top: 2px; }

.tag-cloud { padding: 32px 0; display: flex; gap: 10px; flex-wrap: wrap; }
.tag-cloud .tag { font-size: 0.875rem; cursor: pointer; padding: 4px 14px; }
.tag-cloud .tag.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.search-form { padding: 32px 0; }
.search-form input { width: 100%; padding: 12px 18px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--card-bg); font-family: inherit; font-size: 1rem; color: var(--text); outline: none; transition: border-color 0.2s; }
.search-form input:focus { border-color: var(--accent); }
.search-results { margin-top: 20px; }

.archive { padding: 32px 0; }
.archive-year { font-size: 1.25rem; color: var(--heading); margin: 24px 0 8px; font-weight: normal; }
.archive-month { font-size: 0.9375rem; color: var(--muted); margin: 16px 0 6px; }
.archive-item { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 0.9375rem; }
.archive-item a { color: var(--text); }

.site-footer { text-align: center; padding: 40px 0; border-top: 1px solid var(--border); margin-top: 48px; font-size: 0.8125rem; color: var(--muted); }

.loading { text-align: center; padding: 40px; color: var(--muted); }
.empty { text-align: center; padding: 40px; color: var(--muted); font-style: italic; }

@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .site-title { font-size: 1.375rem; }
  .nav { gap: 16px; }
  .post-item { padding: 18px; }
  .post-item h2 { font-size: 1.125rem; }
  .article h1 { font-size: 1.375rem; }
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
  --bg: #1a1a2e;
  --card-bg: #222240;
  --text: #c8c8d4;
  --heading: #e0d8c8;
  --muted: #8888a0;
  --accent: #c4a882;
  --link: #d4a860;
  --border: #333350;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .article pre { background: #0d0d1a; color: #c8c8d4; }
[data-theme="dark"] .article code { background: #2a2a45; }

[data-theme="dark"] .comment-form input,
[data-theme="dark"] .comment-form textarea,
[data-theme="dark"] .search-form input,
[data-theme="dark"] .meta-row input,
[data-theme="dark"] .slug-row input,
[data-theme="dark"] .write-left textarea { background: #2a2a45; color: #c8c8d4; }

[data-theme="dark"] .toolbar-btn { background: #2a2a45; color: #c8c8d4; border-color: #333350; }

/* ===== Print PDF ===== */
.btn-print {
  margin-left: 12px; padding: 2px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card-bg); color: var(--muted);
  cursor: pointer; font-family: inherit; font-size: 0.75rem;
  vertical-align: middle;
}
.btn-print:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

@media print {
  .site-header, .nav, .toolbar, .site-footer, .comments, .btn-print, .back-to-top, .toc { display: none !important; }
  body { background: #fff; color: #000; font-size: 14px; }
  .article { padding: 0; }
  .article pre { background: #f5f5f5; color: #000; border: 1px solid #ddd; }
}
.back-to-top {
  position: fixed; bottom: 30px; right: 30px;
  width: 40px; height: 40px;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--card-bg); color: var(--text);
  font-size: 1.25rem; cursor: pointer;
  opacity: 0; transition: opacity 0.3s;
  box-shadow: var(--shadow); z-index: 99;
}
.back-to-top:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== Pagination ===== */
.pagination {
  display: flex; justify-content: center; gap: 6px;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.pagination a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.875rem; color: var(--muted);
  transition: all 0.2s;
}
.pagination a:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }
.pagination a.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: bold; }

/* ===== Table of Contents ===== */
.toc {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  margin: 24px 0 0;
}
.toc-title { font-size: 0.875rem; color: var(--heading); font-weight: bold; margin-bottom: 10px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin-bottom: 6px; font-size: 0.875rem; line-height: 1.5; }
.toc li a { color: var(--muted); }
.toc li a:hover { color: var(--link); }
.toc .toc-h3 { padding-left: 16px; font-size: 0.8125rem; }
