:root {
  --bg: #fdfdfb;
  --ink: #1b1b1b;
  --muted: #8a8a85;
  --line: #e8e8e3;
  --accent: #1b873b;
  --accent-soft: #eaf6ec;
  --card: #ffffff;
  --serif: Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", "STSong",
    "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.8;
}

button, input { font: inherit; }

/* ---------- 进度条 ---------- */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 60;
  transition: width 0.1s linear;
}

/* ---------- 头部 ---------- */
.blog-header {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.blog-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--ink);
}

.blog-title:hover {
  color: var(--accent);
}

.blog-sub {
  margin: 2px 0 0;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 4px;
}

.search {
  width: 190px;
  padding: 5px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  outline: none;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
}

.search:focus {
  border-bottom-color: var(--accent);
}

.search::placeholder {
  color: var(--muted);
}

.text-btn {
  border: 0;
  background: none;
  padding: 0;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}

.text-btn:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 主体布局 ---------- */
.app-body {
  flex: 1;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: calc(100vh - 130px);
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.tree {
  overflow-y: auto;
  padding: 22px 12px 40px;
  border-right: 1px solid var(--line);
}

.tree-stats {
  margin: 0 6px 14px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.tree-node {
  margin: 1px 0;
}

.tree-folder {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.tree-folder:hover {
  background: #f2f2ee;
}

.tree-toggle {
  border: 0;
  background: none;
  padding: 0;
  width: 16px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.tree-folder-title {
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-children {
  margin-left: 12px;
  border-left: 1px solid var(--line);
  padding-left: 6px;
}

.tree-link {
  display: block;
  padding: 4px 8px 4px 10px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-link:hover {
  color: var(--ink);
  background: #f2f2ee;
}

.tree-link.active {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- 正文 ---------- */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 34px 28px 60px;
}

.hero {
  margin-bottom: 34px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.hero-kicker {
  margin: 0 0 6px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--accent);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.hero-desc {
  max-width: 620px;
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- 文章卡片 ---------- */
.group-title {
  margin: 34px 0 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.group-title:first-child {
  margin-top: 0;
}

.group-title .en {
  margin-left: 8px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #b5b5af;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease,
    transform 0.18s ease;
}

.post-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgba(27, 135, 59, 0.08);
  transform: translateY(-2px);
}

.post-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.post-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
}

.post-style {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.post-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  background: #f4f4f0;
  padding: 2px 7px;
  border-radius: 6px;
}

.post-date {
  font-family: var(--mono);
  font-size: 11px;
  color: #b5b5af;
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 50px 0;
}

/* ---------- 页脚 ---------- */
.blog-footer {
  padding: 18px 20px 28px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  border-top: 1px solid var(--line);
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .app-body {
    grid-template-columns: 1fr;
  }
  .tree {
    display: none;
  }
  .content {
    padding: 24px 16px 50px;
  }
  .blog-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .search {
    width: 100%;
  }
}

/* ---------- 私密文章标记 ---------- */
.post-style.locked {
  background: #fdf3e3;
  color: #9a6700;
}

.tree-link.locked {
  color: #9a6700;
}

/* ---------- RSA 解锁弹窗 ---------- */
.rsa-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(27, 27, 27, 0.42);
  backdrop-filter: blur(3px);
}

.rsa-box {
  width: min(480px, 100%);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.rsa-kicker {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #9a6700;
}

.rsa-box h2 {
  margin: 0 0 8px;
  font-size: 21px;
  font-weight: 700;
}

.rsa-desc {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

.rsa-key {
  width: 100%;
  min-height: 140px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
  resize: vertical;
}

.rsa-key:focus {
  outline: none;
  border-color: #9a6700;
}

.rsa-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.rsa-file {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rsa-file:hover {
  color: var(--ink);
}

.rsa-login {
  margin-left: auto;
  border: 0;
  background: #9a6700;
  color: #fff;
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.rsa-login:disabled {
  opacity: 0.6;
  cursor: default;
}

.rsa-cancel {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.rsa-cancel:hover {
  color: var(--ink);
}

.rsa-error {
  margin: 12px 0 0;
  font-size: 12px;
  color: #b3261e;
}
