:root {
  --bg-primary: rgb(252, 252, 252);
  --bg-secondary: rgb(240, 240, 244);
  --text-primary: rgb(35, 35, 38);
  --text-muted: rgb(100, 100, 105);
  --text-url: rgb(140, 140, 148);
  --border: rgb(220, 220, 225);
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s ease;

  /* 搜索高亮 */
  --highlight-bg: rgba(255, 214, 0, 0.45);

  /* page_id 徽章 */
  --badge-bg: #3b82f6;
  --badge-text: #ffffff;

  /* 标签 */
  --tag-bg: rgb(230, 230, 236);
  --tag-text: rgb(55, 55, 62);

  /* 详情页 */
  --section-bg: rgb(246, 246, 249);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ========== 顶栏 ========== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 24px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text-primary);
  min-width: 0;
  flex-shrink: 1;
}

.topbar-left:hover {
  opacity: 0.9;
}

.logo {
  height: 36px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.site-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 搜索区域 */
.topbar-search {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}

.search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition);
  flex-shrink: 0;
}

.search-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
}

.search-toggle svg {
  width: 22px;
  height: 22px;
}

.search-form {
  display: flex;
  align-items: center;
  overflow: hidden;
  width: 0;
  transition: width 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.search-form.open {
  width: 240px;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  border-color: var(--badge-bg);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

/* ========== 主内容区 ========== */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ========== 首页统计 ========== */
.stats-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  width: 100%;
  max-width: 640px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
}

.stat-label {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.stat-number-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 56px;
  overflow: hidden;
}

.digit-reel {
  display: inline-block;
  height: 56px;
  overflow: hidden;
  position: relative;
  margin: 0 1px;
}

.digit-strip {
  display: flex;
  flex-direction: column;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.digit-strip span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  font-size: 2.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text-primary);
}

/* ========== 搜索结果页 ========== */
.search-header {
  margin-bottom: 28px;
}

.search-header h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.search-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-item {
  display: block;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  transition: background var(--transition), box-shadow var(--transition);
}

.result-item:hover {
  background: rgb(234, 234, 240);
  box-shadow: var(--card-shadow);
}

.result-title {
  font-size: 1.5rem; /* 150% */
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 10px;
  word-break: break-word;
}

.result-title mark {
  background: var(--highlight-bg);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.result-name {
  font-size: 0.7rem; /* 70% */
  color: var(--text-url);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-badge {
  flex-shrink: 0;
  font-size: 0.5rem; /* 50% */
  font-weight: 600;
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 3px 8px;
  border-radius: 999px; /* 50% 圆角 → 胶囊 */
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ========== 页面详情页 ========== */
.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 14px;
  word-break: break-word;
}

.page-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.page-id-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 4px 10px;
  border-radius: 999px;
}

.page-name {
  font-size: 0.85rem;
  color: var(--text-url);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.page-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tag {
  display: inline-block;
  font-size: 0.8rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 500;
}

.section {
  margin-top: 36px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

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

.file-card {
  background: var(--section-bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.9rem;
}

.file-name {
  font-weight: 600;
  margin-bottom: 6px;
  word-break: break-all;
}

.file-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.file-meta a {
  color: var(--badge-bg);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.revisions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.revision-item {
  background: var(--section-bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
}

.revision-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-bottom: 4px;
}

.rev-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rev-flag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--tag-bg);
  color: var(--tag-text);
}

.rev-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.rev-author {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.rev-comment {
  margin-top: 4px;
  color: var(--text-primary);
  font-size: 0.88rem;
}

.locked-badge {
  display: inline-block;
  font-size: 0.8rem;
  background: #fee2e2;
  color: #b91c1c;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 500;
}

/* 响应式 */
@media (max-width: 560px) {
  .stats-grid {
    grid-template-columns: 1fr;
    max-width: 320px;
  }

  .site-title {
    font-size: 0.95rem;
  }

  .logo {
    height: 30px;
  }

  .topbar {
    padding: 0 12px;
    height: 54px;
  }

  .search-form.open {
    width: 180px;
  }

  .digit-strip span {
    font-size: 2.25rem;
  }

  .stat-number-wrapper,
  .digit-reel,
  .digit-strip span {
    height: 48px;
  }

  .result-title {
    font-size: 1.2rem;
  }

  .page-title {
    font-size: 1.4rem;
  }
}
