/* 古早风格：经典白底黑字、系统默认字体、蓝色超链接 */
:root {
  --bg: #ffffff;
  --text: #000000;
  --link: #0000ee; /* 经典蓝 */
  --visited: #551a8b;
  --muted: #666666;
  --border: #cccccc;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

/* 链接为经典蓝，带下划线 */
a {
  color: var(--link);
  text-decoration: underline;
}
a:visited {
  color: var(--visited);
}
a:hover,
a:focus {
  text-decoration: underline;
}

.site-header {
  margin: 0 0 16px 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.site-title {
  font-size: 28px;
  margin: 0;
}
.site-desc {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

/* 布局：左右两栏（桌面） */
.layout {
  max-width: 1100px;
  margin: 18px auto;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 0 16px;
}
.sidebar {
  width: 300px;
  flex: 0 0 300px;
}
.about {
  border: 1px solid var(--border);
  padding: 12px;
  background: #fff;
}

/* 标签导航 */
.tag-nav {
  margin: 0 0 12px 0;
  padding: 8px 0;
}
.tag-nav a {
  display: inline-block;
  margin: 4px 8px;
  padding: 4px 8px;
  color: var(--link);
  text-decoration: underline;
}
.tag-nav a.active {
  font-weight: bold;
}

/* 可折叠的标签列表 */
.tags-list {
  display: inline-block;
  margin-left: 8px;
}
.tags-list .tag {
  display: inline-block;
  margin: 4px 8px;
  padding: 4px 8px;
  color: var(--link);
  text-decoration: underline;
}
.tags-list .tag.visible {
  font-weight: normal;
}
.tags-list .tag.top {
  font-weight: bold;
}
.tags-list.collapsed .tag:not(.visible) {
  display: none;
}

.tag-toggle {
  margin-left: 8px;
  background: transparent;
  border: 1px dashed var(--border);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--link);
  text-decoration: underline;
  font-size: 13px;
}
.tag-toggle[aria-expanded="true"] {
  font-weight: bold;
}

.content {
  flex: 1;
  min-width: 0;
}
.directory {
  border: 1px solid var(--border);
  padding: 12px;
  background: #fff;
}
.dir-title {
  margin: 0 0 8px;
  font-size: 18px;
}
.dir-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.dir-item {
  padding: 8px 0;
  border-top: 1px dashed var(--border);
}
.dir-item:first-child {
  border-top: 0;
}
.dir-item a {
  color: var(--link);
  text-decoration: underline;
}
.dir-item .meta {
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-top: 4px;
}

/* 文章页面容器：左右保留固定留白，宽屏时内容宽度受限 */
.post-content {
  max-width: 820px; /* 最大内容宽度 */
  margin: 0 auto; /* 居中 */
  padding: 24px 16px; /* 上下留白较大，左右固定留白 */
  box-sizing: border-box;
}

/* 大屏时增加左右留白但仍受 max-width 限制 */
@media (min-width: 1200px) {
  .post-content {
    padding-left: 48px;
    padding-right: 48px;
  }
}

/* 图片与代码在文章中自适应 */
.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px 0;
}
.post-content pre {
  overflow: auto;
  padding: 12px;
  background: #f6f6f6;
  border: 1px solid var(--border);
}

.site-footer {
  max-width: 900px;
  margin: 30px auto;
  padding: 12px 16px;
  color: var(--muted);
  text-align: center; /* 居中页脚文本 */
}

.loading {
  color: var(--muted);
}

@media (min-width: 801px) {
  /* 桌面：仅在两栏布局时隐藏页面滚动条，让右侧区域可滚动，左侧保持固定 */
  .layout {
    height: calc(100vh - 80px);
    overflow: hidden; /* 仅限制 layout 的滚动，避免影响单篇文章页 */
  }
  .sidebar {
    position: sticky;
    top: 18px;
    align-self: flex-start;
  }
  .content {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 12px;
  }
}

@media (max-width: 800px) {
  /* 小屏回到单列，恢复页面滚动 */
  body {
    overflow: visible;
  }
  .layout {
    flex-direction: column;
    padding: 0 12px;
  }
  .sidebar {
    width: auto;
    flex: none;
  }
  .site-title {
    font-size: 24px;
  }
  .site-header {
    margin: 16px;
    padding: 12px;
  }
  .directory {
    margin-top: 16px;
  }
}
