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

:root {
  --bg:        #F5F6F2;
  --text:      #111315;
  --primary:   #1F473D;
  --accent:    #4E7386;
  --line:      #D6DDD7;
  --soft:      #BFC7C1;
  --sidebar-w: 300px;
  --max-w:     920px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "LXGW WenKai", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 2;
}

::selection { background: var(--primary); color: #fff; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary); }

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

.site { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); padding: 48px 40px;
  border-right: 1px solid var(--line);
  background: var(--bg); z-index: 10; overflow-y: auto;
}

.sidebar-inner { display: flex; flex-direction: column; gap: 24px; }

.logo {
  display: block; font-size: 26px; font-weight: 600;
  color: var(--primary); letter-spacing: -0.02em;
}

.desc {
  font-size: 13px; color: var(--accent);
  letter-spacing: 0.05em; line-height: 1.6;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 10px; }
.sidebar-nav a { font-size: 15px; color: var(--text); transition: color .2s; }
.sidebar-nav a:hover { color: var(--primary); }

.sidebar-section { margin-top: 8px; }

.sidebar-section h3 {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .1em; color: var(--soft); margin-bottom: 8px;
}

.category-list { list-style: none; padding: 0; }
.category-list li { margin: 4px 0; }
.category-list a { font-size: 14px; color: var(--accent); }
.category-list a:hover { color: var(--primary); }

.sidebar-footer { margin-top: auto; font-size: 12px; color: var(--soft); }

.content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }

.stream { max-width: var(--max-w); padding: 80px; }

.post-card { display: flex; gap: 40px; margin-bottom: 80px; align-items: flex-start; }

.post-cover { width: 340px; flex: none; overflow: hidden; border-radius: 2px; }
.post-cover a { display: block; }
.post-cover img { width: 100%; aspect-ratio: 4/3; object-fit: cover; transition: transform .4s; }
.post-cover:hover img { transform: scale(1.03); }

.post-info { flex: 1; display: flex; flex-direction: column; justify-content: center; }

.post-date { font-size: 12px; letter-spacing: .2em; color: var(--accent); margin-bottom: 8px; }
.post-title { font-size: 26px; font-weight: 400; line-height: 1.3; margin-bottom: 12px; }
.post-title a:hover { color: var(--primary); }

.post-excerpt { font-size: 15px; color: #555; line-height: 1.8; margin-bottom: 16px; }
.post-more {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--primary);
  letter-spacing: .05em;
}
.post-roll-label { flex: none; }
.post-films { display: flex; gap: 8px; min-width: 0; }
.post-film {
  display: block;
  width: 85px;
  aspect-ratio: 1;
  flex: none;
  border-radius: 2px;
  object-fit: cover;
}

.pagination {
  list-style: none;
  padding: 0;
  margin-top: 60px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pagination li {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 14px;
}
.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: var(--accent);
  transition: color .2s;
}
.pagination a:hover { color: var(--primary); }
.pagination .current {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
}
.pagination .prev,
.pagination .next { display: none; }

.article { max-width: 1152px; margin: 0 auto; padding: 80px 80px 120px; }
.article-header { margin-bottom: 48px; }
.article-date { display: block; font-size: 14px; letter-spacing: .2em; color: var(--accent); margin-bottom: 16px; }
.article h1 { font-size: 36px; font-weight: 400; line-height: 1.3; letter-spacing: -.02em; }
.article-hero { width: 100%; margin: 12px 0; border-radius: 2px; }

.article-entry { font-size: 16px; line-height: 2; }
.article-entry a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.article-entry a:hover { opacity: .8; }
.article-entry p { margin: 1.6em 0; }
.article-entry img { max-width: 100%; border-radius: 2px; }
.article-entry p:has(img:only-child) { text-align: center; }
.article-entry p:has(img:only-child) img { display: inline-block; max-width: 100%; border-radius: 2px; }
.article-entry p:has(img ~ img) { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; align-items: flex-start; }
.article-entry p:has(img ~ img) img { flex: none; max-width: 100%; height: auto; border-radius: 2px; }
.article-entry h2 { font-size: 24px; font-weight: 500; margin: 48px 0 16px; }
.article-entry h3 { font-size: 20px; font-weight: 500; margin: 36px 0 12px; }

.article-entry blockquote { padding-left: 24px; border-left: 2px solid var(--primary); color: #666; font-style: italic; margin: 1.6em 0; }
.article-entry hr { border: none; height: 1px; background: var(--line); margin: 48px 0; }
.article-entry pre { padding: 20px 24px; overflow-x: auto; background: #EDEFEA; border-radius: 2px; font-size: 14px; line-height: 1.7; margin: 24px 0; }
.article-entry code { background: #EDEFEA; padding: 2px 6px; font-size: 14px; border-radius: 2px; }
.article-entry pre code { background: none; padding: 0; }
.article-entry ul, .article-entry ol { padding-left: 24px; margin: 1em 0; }
.article-entry li { margin: 6px 0; }
.article-entry table { width: 100%; border-collapse: collapse; margin: 24px 0; }
.article-entry th, .article-entry td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; }
.article-entry th { font-weight: 600; background: #EDEFEA; }

.reading-time { margin-top: 48px; padding: 16px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--accent); letter-spacing: .05em; }

.archive { max-width: 740px; margin: 0 auto; padding: 80px; }
.archive h1 { font-size: 28px; font-weight: 400; margin-bottom: 40px; color: var(--primary); }
.archive-item { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.archive-item:hover { color: var(--primary); }
.archive-item span { font-size: 16px; }
.archive-item time { font-size: 13px; color: var(--accent); flex: none; }

.notfound { max-width: 500px; margin: 120px auto; padding: 0 40px; text-align: center; }
.notfound .code { font-size: 72px; font-weight: 200; color: var(--accent); line-height: 1; margin-bottom: 16px; }
.notfound h1 { font-size: 22px; font-weight: 400; margin-bottom: 16px; }
.notfound p { font-size: 15px; color: #666; margin-bottom: 32px; }
.notfound a { display: inline-block; padding: 10px 28px; border: 1px solid var(--primary); color: var(--primary); font-size: 14px; }
.notfound a:hover { background: var(--primary); color: #fff; }

/* Image lightbox */
.lightbox {
  visibility: hidden;
  opacity: 0;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(17,19,21,.35);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: opacity .25s ease;
}
.lightbox.active {
  visibility: visible;
  opacity: 1;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: zoom-in;
  transition: transform .15s ease;
}

/* Table of contents */
.toc {
  display: none;
  position: fixed;
  right: calc((100vw - 1152px) / 2 - 226px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  width: 210px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px 18px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.toc.show { display: block; }
.toc h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--soft);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 10px;
}
.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 4px 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--accent);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all .2s;
}
.toc a:hover {
  color: var(--primary);
  border-left-color: var(--primary);
}
.article-entry h2 { scroll-margin-top: 24px; }

/* Single post/page: hide sidebar */
.single .sidebar { display: none; }
.single .content { margin-left: 0; }

/* Back to home button */
.back-home {
  display: none;
  position: fixed;
  top: 32px;
  left: 32px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 18px;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all .2s;
}
.back-home:hover {
  color: var(--primary);
  border-color: var(--primary);
}
.single .back-home { display: flex; }

/* Article meta */
.article-meta {
  font-size: 13px;
  color: var(--accent);
  margin-top: 8px;
  letter-spacing: 0.03em;
}

/* Article footer */
.article-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--soft);
  flex-wrap: wrap;
  gap: 8px;
}
.article-footer a { color: var(--accent); text-decoration: none; }
.article-footer a:hover { color: var(--primary); }

@media (max-width: 860px) {
  .site { flex-direction: column; }
  .sidebar { position: relative; width: 100%; padding: 28px 24px; border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar-inner { gap: 16px; }
  .content { margin-left: 0; }
  .stream { padding: 24px; }
  .post-card { flex-direction: column; gap: 20px; margin-bottom: 48px; }
  .post-cover { width: 100%; }
  .post-cover img { aspect-ratio: 16/9; }
  .post-title { font-size: 22px; }
  .post-more { gap: 10px; }
  .post-films { gap: 6px; }
  .post-film { width: 64px; }
  .article { padding: 40px 24px; }
  .article h1 { font-size: 28px; }
  .archive { padding: 40px 24px; }
  .archive h1 { font-size: 22px; }
  .archive-item { flex-direction: column; gap: 4px; }
  .notfound { margin: 80px auto; }
}

@media (prefers-color-scheme: dark) {
  :root { --bg: #141717; --text: #ECEDEB; --primary: #2F6555; --accent: #6C93A5; --line: #2D3434; --soft: #4A5454; }
  body { background: var(--bg); }
  img { opacity: .95; }
  .sidebar { background: var(--bg); }
  .article-entry pre, .article-entry code, .article-entry th { background: #1F2323; }
  .post-excerpt { color: #999; }
}
