:root {
  --bg: #f7f7f7;
  --card: #ffffff;
  --text: #222222;
  --muted: #666666;
  --link: #1a5fb4;
  --border: #e2e2e2;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 14px;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-grid {
  display: grid;
  grid-template-columns: 120px 1fr 120px;
  align-items: center;
  min-height: 64px;
}
.header-left {
  display: flex;
  align-items: center;
}
.icon-link {
  width: 44px;
  height: 44px;
  justify-content: center;
}
.site-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #1a5fb4;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.site-icon.site-icon-img {
  padding: 0;
  background: transparent;
  object-fit: cover;
  display: block;
}

.header-center {
  text-align: center;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.header-center a {
  color: #222;
}
.nav-sep {
  color: #8d8d8d;
  font-size: 13px;
}

.header-right {
  display: flex;
  justify-content: flex-end;
}
.search-trigger {
  border: 1px solid #d0d0d0;
  background: #fff;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
}

.search-form { margin: 0; }
.search-input {
  width: 100%;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 14px;
  outline: none;
}
.search-input:focus { border-color: #8ab4f8; }

.hero {
  padding: 8px 0 10px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 32px;
}
.muted { color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding-bottom: 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px 16px;
}
.card-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 500;
}
.meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tag {
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  padding: 2px 10px;
  text-decoration: none;
}
a.tag:hover {
  border-color: #8ab4f8;
  color: var(--link);
  text-decoration: none;
}
.empty {
  background: #fff;
  border: 1px dashed #ccc;
  padding: 16px;
}

.content-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  padding-top: 14px;
  min-height: calc(100vh - 120px);
}
.content-layout--with-toc {
  grid-template-columns: 260px minmax(0, 1fr) 220px;
  max-width: 1320px;
}
.article-list-pane,
.article-content-pane {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.article-list-pane {
  padding: 10px;
  align-self: start;
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 96px);
  overflow: auto;
}
.pane-title {
  margin: 4px 6px 10px;
  font-size: 15px;
}
.article-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.article-list-item {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
}
.article-list-item + .article-list-item {
  margin-top: 6px;
}
.article-list-item:hover {
  background: #fafafa;
  border-color: #efefef;
}
.article-list-item.is-active {
  background: #f4f8ff;
  border-color: #d8e4ff;
}
.article-list-item a {
  display: block;
  width: 100%;
  height: 100%;
  padding: 8px 10px;
  color: #222;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.article-list-item a:hover,
.article-list-item a:focus-visible {
  text-decoration: none;
}
.article-list-title {
  display: block;
}

.article-content-pane {
  padding: 16px 18px;
}

.prose { padding: 4px 0 18px; }
.breadcrumbs {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}
.prose h1 {
  margin: 6px 0 10px;
  font-size: 34px;
  font-weight: 500;
}
.prose h2 { margin: 22px 0 8px; font-size: 26px; font-weight: 500; }
.prose h3 { margin: 18px 0 6px; font-size: 20px; font-weight: 500; }
.prose p { margin: 10px 0; }
.prose ul { padding-left: 22px; }
.prose img {
  max-width: 100%;
  height: auto;
  display: block;
}
.prose blockquote {
  margin: 14px 0;
  padding: 6px 12px;
  border-left: 3px solid #ccc;
  color: #555;
  background: #fcfcfc;
}
.prose pre {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.prose pre.mermaid {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafafa;
  padding: 12px;
  margin: 14px 0;
}
.prose pre.mermaid svg {
  display: block;
  max-width: none;
  height: auto;
}
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
}
.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.prose thead th {
  background: #f5f5f5;
  font-weight: 600;
}

.site-footer {
  background: #fff;
  border-top: 1px solid var(--border);
  color: var(--muted);
  padding: 16px 0;
  margin-top: 12px;
}
.site-footer .container {
  text-align: center;
}

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 12px 12px;
}
.search-overlay.open {
  display: flex;
}
.search-modal {
  width: min(820px, 100%);
  background: #fff;
  border-radius: 8px;
  border: 1px solid #ddd;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  padding: 14px;
}
.search-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.search-close {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
}
.search-inline-results {
  margin-top: 12px;
  max-height: 56vh;
  overflow: auto;
}

/* Mobile: full width, same list/content ratio as desktop (260:1fr ≈ 26:74), no TOC aside */
@media (max-width: 760px) {
  .container {
    max-width: none;
    width: 100%;
    padding: 0 8px;
  }

  .header-grid {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 52px;
  }
  .header-center {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    font-size: 12px;
    gap: 6px;
    scrollbar-width: none;
  }
  .header-center::-webkit-scrollbar {
    display: none;
  }
  .header-center a,
  .nav-sep {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .search-trigger {
    padding: 6px 10px;
    font-size: 13px;
  }

  .content-layout,
  .content-layout--with-toc {
    width: 100%;
    max-width: none;
    grid-template-columns: minmax(0, 26%) minmax(0, 1fr);
    gap: 8px;
    padding-top: 8px;
    min-height: 0;
  }
  .post-toc-aside {
    display: none !important;
  }
  .article-list-pane {
    padding: 6px;
    top: 56px;
    max-height: calc(100vh - 64px);
  }
  .pane-title {
    font-size: 13px;
    margin: 2px 4px 6px;
  }
  .article-list-item a {
    padding: 6px 8px;
  }
  .article-list-title {
    font-size: 12px;
    line-height: 1.35;
    word-break: break-word;
  }
  .article-list-item .meta {
    display: none;
  }
  .article-content-pane {
    padding: 10px 12px;
    min-width: 0;
  }

  .hero h1 { font-size: 24px; }
  .prose h1 { font-size: 24px; line-height: 1.3; }
  .prose h2 { font-size: 20px; }
  .prose h3 { font-size: 17px; }
  .prose h2[id],
  .prose h3[id],
  .prose h4[id] {
    scroll-margin-top: 72px;
  }

  .prose table {
    font-size: 12px;
  }
  .prose th,
  .prose td {
    padding: 6px 8px;
  }
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 14px 0;
    border: 1px solid var(--border);
    border-radius: 4px;
  }
  .table-scroll table {
    margin: 0;
    min-width: 480px;
  }

  .code-block-wrap pre.shiki,
  .code-block-wrap pre.code-block {
    font-size: 12px;
    padding: 2rem 2.75rem 0.65rem 0.65rem;
  }

  .prose pre.mermaid svg {
    max-width: 100%;
    height: auto;
  }

  .post-nav {
    flex-direction: column;
  }
  .post-nav-link {
    flex: 1 1 auto;
    text-align: left;
  }
  .post-nav-next {
    text-align: left;
  }
}

.post-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.reading-time::before {
  content: "·";
  margin-right: 12px;
  color: #ccc;
}

.post-toc-aside {
  align-self: start;
  min-width: 0;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow: auto;
}
.post-toc-aside .post-toc {
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fafafa;
}
.post-toc-aside .post-toc::before {
  content: "本页目录";
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
}
.post-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-toc ul ul {
  padding-left: 14px;
}
.post-toc a {
  display: block;
  padding: 3px 0;
  color: var(--muted);
  text-decoration: none;
}
.post-toc a:hover,
.post-toc a.is-active {
  color: var(--link);
}

.prose h2[id],
.prose h3[id],
.prose h4[id] {
  scroll-margin-top: 88px;
}
.prose h2 .header-anchor,
.prose h3 .header-anchor,
.prose h4 .header-anchor {
  opacity: 0;
  margin-right: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 400;
}
.prose h2:hover .header-anchor,
.prose h3:hover .header-anchor,
.prose h4:hover .header-anchor {
  opacity: 1;
}

.admonition {
  margin: 14px 0;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.admonition-title {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 14px;
}
.admonition-tip { background: #f0f9f4; border-color: #b8e0c8; }
.admonition-warning { background: #fff8e6; border-color: #f0d78c; }
.admonition-danger { background: #fff0f0; border-color: #f0b8b8; }
.admonition-info { background: #f0f6ff; border-color: #b8d4f8; }
.admonition-note { background: #f7f7f7; border-color: #ddd; }

.prose .task-list-item {
  list-style: none;
}
.prose .task-list-item input {
  margin-right: 8px;
}

.code-block-wrap {
  position: relative;
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.code-block-wrap pre {
  margin: 0;
  border: none;
  border-radius: 0;
}
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  z-index: 1;
}
.code-lang-label {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
  z-index: 1;
}
.image-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.image-lightbox.open {
  display: flex;
}
.image-lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
}

.related-posts { margin-top: 20px; }
.related-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.related-list li {
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.related-list li:last-child { border-bottom: none; }
.related-list .meta {
  display: block;
  margin: 2px 0 0;
}

.post-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.post-nav-link {
  flex: 1 1 200px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
  color: #222;
  text-decoration: none;
  font-size: 14px;
}
.post-nav-link:hover {
  border-color: #8ab4f8;
  text-decoration: none;
}
.post-nav-next { text-align: right; }

.tag-cloud {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tag-cloud li {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
}

.post-encrypted-badge {
  font-size: 14px;
  font-weight: 600;
  color: #8a4b00;
  background: #fff8e6;
  border: 1px solid #f0d78c;
  border-radius: 4px;
  padding: 2px 8px;
  vertical-align: middle;
}
.article-lock {
  opacity: 0.75;
}
.article-list-item.is-encrypted .article-list-title {
  color: #555;
}
.post-encrypt-gate {
  margin: 16px 0;
}
.post-encrypt-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-top: 12px;
}
.post-encrypt-label {
  width: 100%;
  font-size: 13px;
  color: var(--muted);
}
.post-encrypt-input {
  flex: 1 1 180px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 15px;
}
.post-encrypt-submit {
  border: 1px solid #1a5fb4;
  background: #1a5fb4;
  color: #fff;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}
.post-encrypt-submit:hover {
  background: #164f96;
}
.post-encrypt-error {
  margin: 10px 0 0;
  color: #b42318;
  font-size: 13px;
}
.post-body-locked[hidden] {
  display: none !important;
}
.post-encrypt-gate[hidden] {
  display: none !important;
}
#post-decrypted-content .post-toc {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
  font-size: 13px;
}
#post-decrypted-content .post-toc::before {
  content: "本页目录";
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

