:root {
  --bg-page: #ebe4d6;
  --bg-shell: #faf7f0;
  --bg-sidebar: #2b2925;
  --bg-card: #fffdf8;
  --ink: #2c2925;
  --ink-soft: #6a635a;
  --line: #e2d8c6;
  --accent: #9a3b2a;
  --accent-gold: #b0894f;
  --sidebar-text: #cfc6b8;
  --sidebar-muted: #8a8176;
  --sidebar-width: 13.75rem;
  --shell-width: 70rem;
  --content-width: 44rem;
  --radius: 4px;
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC",
    "SimSun", "Times New Roman", serif;
  --font-mono: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono",
    "PingFang SC", monospace;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg-shell);
  font-family: var(--font-ui);
  line-height: 1.7;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------------ */
/* Shell: centered on desktop, full-width on small screens            */
/* ------------------------------------------------------------------ */

#layout {
  position: relative;
  min-height: 100vh;
}

#main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-shell);
}

.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.site-footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
}

.site-footer p {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
}

.footer-sep {
  opacity: 0.6;
}

/* ------------------------------------------------------------------ */
/* Mobile top bar + hamburger                                         */
/* ------------------------------------------------------------------ */

.mobile-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 3rem;
  padding: 0 3.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-shell);
  position: sticky;
  top: 0;
  z-index: 50;
}

.mobile-bar-title {
  color: var(--ink);
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-decoration: none;
}

.mobile-bar-title:hover {
  text-decoration: none;
  color: var(--accent);
}

.menu-link {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  background: rgba(43, 41, 37, 0.92);
  color: #fff;
  text-decoration: none;
}

.menu-link:hover,
.menu-link:focus {
  background: #1c1b18;
}

.menu-link span,
.menu-link span::before,
.menu-link span::after {
  display: block;
  width: 1.15rem;
  height: 2px;
  background: #fff;
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-link span::before,
.menu-link span::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-link span::before {
  top: -0.38rem;
}

.menu-link span::after {
  top: 0.38rem;
}

.menu-link.active span {
  background: transparent;
}

.menu-link.active span::before {
  top: 0;
  transform: rotate(45deg);
}

.menu-link.active span::after {
  top: 0;
  transform: rotate(-45deg);
}

.menu-overlay {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Sidebar                                                            */
/* ------------------------------------------------------------------ */

#menu {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 1000;
  background: var(--bg-sidebar);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
}

#menu.active,
#layout.active #menu {
  transform: translateX(0);
}

#menu .pure-menu {
  border: none;
  background: transparent;
}

#menu a {
  text-decoration: none;
}

#menu .pure-menu-heading {
  display: block;
  color: #f4ead8;
  background: transparent;
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  padding: 1.35rem 1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-transform: none;
}

#menu .pure-menu-heading:hover {
  color: #fff;
  background: transparent;
}

#menu .pure-menu-list {
  border: none;
  background: transparent;
}

#menu .menu-item-divided {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#menu .menu-label {
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  padding: 0.7rem 1rem 0.25rem;
}

#menu .pure-menu-link {
  color: var(--sidebar-text);
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

#menu .pure-menu-link:hover,
#menu .pure-menu-link:focus {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}

#menu .pure-menu-selected > .pure-menu-link,
#menu .pure-menu-selected > .pure-menu-link:hover {
  background: rgba(176, 137, 79, 0.18);
  color: #f3e3c3;
}

.menu-count {
  font-size: 0.72rem;
  color: var(--sidebar-muted);
  min-width: 1.4em;
  text-align: right;
}

#menu .pure-menu-selected .menu-count {
  color: var(--accent-gold);
}

#menu .pure-menu-children {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.75rem;
}

/* ------------------------------------------------------------------ */
/* Page headers                                                       */
/* ------------------------------------------------------------------ */

.header {
  text-align: center;
  padding: 2rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--ink);
}

.header-subtitle {
  margin: 0.65rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
}

.home-intro,
.section-intro {
  color: var(--ink-soft);
  margin: 0 0 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed var(--line);
  font-size: 0.98rem;
}

.home-intro p,
.section-intro p {
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* Post list                                                          */
/* ------------------------------------------------------------------ */

.post-list {
  display: flex;
  flex-direction: column;
}

.post-card {
  padding: 1.35rem 0;
  border-bottom: 1px solid var(--line);
}

.post-card-title {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.45;
}

.post-card-title a {
  color: var(--ink);
}

.post-card-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-card-meta {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 0.45rem;
}

.post-card-meta a {
  color: var(--ink-soft);
}

.post-card-meta a:hover {
  color: var(--accent);
}

.meta-sep {
  margin: 0 0.35rem;
  opacity: 0.7;
}

.post-card-summary {
  color: #4d4842;
  font-size: 0.95rem;
  line-height: 1.75;
}

.read-more {
  display: inline-block;
  margin-top: 0.45rem;
  font-size: 0.85rem;
}

.empty-hint {
  color: var(--ink-soft);
}

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

.page-info {
  color: var(--ink-soft);
  font-size: 0.9rem;
  min-width: 4.5em;
  text-align: center;
}

.pure-button {
  background: #f3eee4;
  color: var(--ink);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-size: 0.9rem;
}

.pure-button:hover,
.pure-button:focus {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
}

.pure-button-disabled,
.pure-button-disabled:hover {
  background: #f3eee4;
  color: #b3aaa0;
  border-color: var(--line);
  opacity: 1;
  cursor: default;
}

.term-index {
  list-style: none;
  margin: 0;
  padding: 0;
}

.term-index li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.term-index a {
  color: var(--ink);
  font-size: 1.05rem;
}

.term-index a:hover {
  color: var(--accent);
  text-decoration: none;
}

.term-index .menu-count {
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ */
/* Article                                                            */
/* ------------------------------------------------------------------ */

.article-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.article-header h1 {
  margin: 0 0 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.04em;
}

.article-meta {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.article-meta a {
  color: var(--ink-soft);
}

.article-meta a:hover {
  color: var(--accent);
}

.toc {
  background: #f3eee4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.75rem;
  font-size: 0.92rem;
}

.toc h2 {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

.toc #TableOfContents ul {
  margin: 0;
  padding-left: 1.1rem;
}

.toc #TableOfContents li {
  margin: 0.25rem 0;
}

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

.article-body {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  line-height: 1.95;
  color: #2a2724;
  word-break: break-word;
}

.article-body > *:first-child {
  margin-top: 0;
}

.article-body h2,
.article-body h3,
.article-body h4 {
  font-family: var(--font-ui);
  font-weight: 600;
  line-height: 1.4;
  margin: 1.8em 0 0.7em;
  color: var(--ink);
  scroll-margin-top: 4rem;
}

.article-body h2 {
  font-size: 1.28rem;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--line);
}

.article-body h3 {
  font-size: 1.12rem;
}

.article-body p {
  margin: 1.05em 0;
}

.article-body a {
  border-bottom: 1px solid rgba(154, 59, 42, 0.35);
}

.article-body a:hover {
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.article-body ul,
.article-body ol {
  margin: 1em 0;
  padding-left: 1.6em;
}

.article-body li + li {
  margin-top: 0.3em;
}

.article-body hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 2.2em auto;
  max-width: 8rem;
}

.article-body blockquote {
  margin: 1.6em auto;
  padding: 0.4em 0 0.4em 1em;
  border-left: 3px solid var(--accent-gold);
  color: #3a3631;
}

.article-body blockquote p {
  margin: 0.35em 0;
}

/* Classical poems sit centered with looser leading. */
.is-poem .article-body {
  text-align: center;
  line-height: 2.15;
  letter-spacing: 0.08em;
}

.is-poem .article-body p,
.is-poem .article-body > blockquote {
  text-align: center;
}

.article-posts .article-body > blockquote,
.is-poem .article-body > blockquote {
  max-width: 22em;
  text-align: center;
  border-left: none;
  padding: 0.6em 0.5em;
  font-size: 1.12em;
  line-height: 2.15;
  letter-spacing: 0.12em;
}

.is-poem .article-body ul,
.is-poem .article-body ol,
.is-poem .article-body small {
  text-align: left;
  letter-spacing: 0;
  line-height: 1.8;
}

.is-verse .article-body p {
  margin: 0.85em 0;
  line-height: 2;
}

.is-poem .article-body p,
.is-verse .article-body p {
  white-space: pre-line;
}

.is-poem .article-body p:has(br),
.is-verse .article-body p:has(br) {
  white-space: normal;
}

.article-body small {
  display: block;
  margin: 1em 0 0;
  color: var(--ink-soft);
  font-size: 0.82em;
  line-height: 1.7;
  font-family: var(--font-ui);
  letter-spacing: 0;
}

.article-body img,
.article-body .pure-img,
.article-body iframe {
  display: block;
  margin: 1.5em auto;
  max-width: 100%;
}

.article-body img,
.article-body .pure-img {
  border-radius: var(--radius);
}

.article-body figure {
  margin: 1.5em 0;
}

.article-body figcaption {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-family: var(--font-ui);
  margin-top: 0.4rem;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: #efe8da;
  padding: 0.12em 0.38em;
  border-radius: 3px;
}

.article-body pre {
  overflow-x: auto;
  background: #f4efe4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 1.4em 0;
  font-size: 0.86rem;
  line-height: 1.6;
}

.article-body pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

.table-wrap,
.article-body .highlight {
  overflow-x: auto;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  margin: 1.4em 0;
}

.article-body th,
.article-body td {
  border: 1px solid var(--line);
  padding: 0.45em 0.7em;
  text-align: left;
}

.article-body th {
  background: #f3eee4;
}

.article-body .footnotes {
  margin-top: 2.5em;
  padding-top: 1em;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  font-family: var(--font-ui);
  color: var(--ink-soft);
}

.article-footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.term-list {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.term-label {
  color: var(--ink-soft);
  flex-shrink: 0;
}

.term-list ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.term-list a {
  display: inline-block;
  padding: 0.15em 0.65em;
  background: #f3eee4;
  color: var(--ink);
  border-radius: 999px;
  font-size: 0.85rem;
}

.term-list a:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

.post-nav-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 0.9rem;
  background: #f3eee4;
  border-radius: var(--radius);
  color: var(--ink);
  min-width: 0;
}

.post-nav-item:hover {
  text-decoration: none;
  background: #ebe3d4;
}

.post-nav-older {
  text-align: right;
}

.post-nav-label {
  font-size: 0.75rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}

.post-nav-title {
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-nav-empty {
  background: transparent;
}

.not-found {
  text-align: center;
  padding: 3rem 0 2rem;
}

.not-found h1 {
  font-family: var(--font-serif);
  font-size: 3rem;
  margin: 0 0 0.75rem;
  font-weight: 500;
}

.not-found p {
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ */
/* Desktop: centered shell, persistent left nav                       */
/* ------------------------------------------------------------------ */

@media (min-width: 48em) {
  body {
    background: var(--bg-page);
  }

  #layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    max-width: var(--shell-width);
    margin: 0 auto;
    background: var(--bg-shell);
    box-shadow:
      0 0 0 1px rgba(60, 45, 25, 0.06),
      0 18px 50px rgba(40, 30, 15, 0.08);
  }

  #menu {
    position: sticky;
    top: 0;
    left: auto;
    bottom: auto;
    height: 100vh;
    transform: none;
    z-index: 1;
  }

  #menu.active,
  #layout.active #menu {
    transform: none;
  }

  .menu-link,
  .mobile-bar,
  .menu-overlay {
    display: none !important;
  }

  .header {
    padding: 2.6rem 2rem 1.4rem;
  }

  .header h1 {
    font-size: 2.35rem;
  }

  .content {
    padding: 1.75rem 2.5rem 4rem;
  }

  .article-header h1 {
    font-size: 2rem;
  }

  .article-body {
    font-size: 1.12rem;
  }

  .article-body h2,
  .article-body h3,
  .article-body h4 {
    scroll-margin-top: 1.2rem;
  }
}

@media (max-width: 47.999em) {
  body.menu-open {
    overflow: hidden;
  }

  .menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 16, 12, 0.45);
    z-index: 900;
  }

  #layout.active .menu-overlay,
  .menu-overlay.is-visible {
    display: block;
  }
}

/* ------------------------------------------------------------------ */
/* Print                                                              */
/* ------------------------------------------------------------------ */

@media print {
  body {
    background: #fff;
    color: #000;
  }

  #menu,
  .menu-link,
  .mobile-bar,
  .menu-overlay,
  .pagination,
  .post-nav,
  .site-footer {
    display: none !important;
  }

  #layout,
  #main,
  .content {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
    background: #fff;
  }

  .article-body a {
    color: inherit;
    border-bottom: none;
  }
}
