/* ============================================
   流明智库 · 公用样式
   ============================================ */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1a1d21;
  --text-2: #5a6472;
  --text-3: #8b95a3;
  --border: #e1e4e8;
  --accent: #0d9488;
  --accent-2: #14b8a6;
  --accent-soft: #ccfbf1;
  --tag-bg: #eef1f4;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: 56px; display: flex; align-items: center; gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  font-weight: 600; font-size: 15px; white-space: nowrap;
}
.brand-mark { color: var(--accent); font-size: 18px; }
.search-wrap { flex: 1; max-width: 360px; }
#siteSearch {
  width: 100%; height: 34px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-family: var(--font); font-size: 13px;
  color: var(--text); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#siteSearch:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 条目页布局 ---------- */
.page {
  max-width: 1200px; margin: 0 auto; padding: 24px;
  display: grid; grid-template-columns: 220px 1fr;
  gap: 32px; align-items: start;
}

/* ---------- 侧栏 ---------- */
.sidebar {
  position: sticky; top: 80px;
  max-height: calc(100vh - 104px);
  overflow-y: auto; padding-right: 4px;
}
.nav-group { margin-bottom: 20px; }
.nav-title {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
  display: block; padding: 6px 10px;
  border-radius: var(--radius-sm); font-size: 13.5px;
  color: var(--text-2); text-decoration: none;
  cursor: pointer; transition: background 0.12s, color 0.12s;
}
a.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.nav-item.stub { opacity: 0.55; cursor: default; }
.nav-item.stub:hover { background: transparent; color: var(--text-2); }

/* ---------- 正文 ---------- */
.main { min-width: 0; }
.entry {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 32px 36px 28px;
}
.entry-head { margin-bottom: 20px; }
.entry-tags { display: flex; gap: 6px; margin-bottom: 10px; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500;
  background: var(--tag-bg); color: var(--text-2);
}
.tag-region { background: #e0f2fe; color: #0369a1; }
.tag-port { background: #ccfbf1; color: #0f766e; }
.tag-org { background: #fef3c7; color: #92400e; }
.tag-person { background: #fce7f3; color: #9d174d; }
.tag-concept { background: #ede9fe; color: #5b21b6; }
.tag-city     { background: #dbeafe; color: #1d4ed8; }
.tag-street   { background: #fef9c3; color: #854d0e; }
.tag-park     { background: #dcfce7; color: #166534; }
.tag-under    { background: #cffafe; color: #155e75; }
.tag-hospital { background: #ffe4e6; color: #9f1239; }
.tag-museum   { background: #f3e8ff; color: #6b21a8; }
.tag-company  { background: #ffedd5; color: #9a3412; }
.entry-title {
  font-size: 28px; font-weight: 700;
  letter-spacing: -0.01em; line-height: 1.3; margin-bottom: 6px;
}
.entry-subtitle { font-size: 14px; color: var(--text-2); line-height: 1.6; }

.entry-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
  margin-bottom: 28px;
}
.meta-item {
  background: var(--surface); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.meta-key { font-size: 11px; color: var(--text-3); font-weight: 500; }
.meta-val { font-size: 13px; color: var(--text); }

.entry-body h2 {
  font-size: 17px; font-weight: 600;
  margin: 28px 0 10px; padding-left: 12px;
  border-left: 3px solid var(--accent); line-height: 1.4;
  scroll-margin-top: 72px;
}
.entry-body h2:first-child { margin-top: 0; }
.entry-body p { margin-bottom: 12px; color: var(--text); }
.entry-body strong { font-weight: 600; color: var(--accent); }
.entry-body em {
  font-style: normal; background: var(--surface-2);
  padding: 1px 6px; border-radius: 3px; font-size: 13px;
}
.entry-body ul { margin: 0 0 14px 0; padding-left: 0; list-style: none; }
.entry-body li {
  position: relative; padding-left: 18px;
  margin-bottom: 6px; color: var(--text);
}
.entry-body li::before {
  content: ""; position: absolute; left: 4px; top: 11px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2);
}

.related { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.related-link {
  display: inline-block; padding: 5px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; font-size: 13px; color: var(--text-2);
  text-decoration: none; transition: all 0.15s;
}
.related-link:hover {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-soft);
}

.entry-foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border); }
.entry-foot p { font-size: 12px; color: var(--text-3); }

/* ---------- 首页 ---------- */
.home-wrap {
  max-width: 1200px; margin: 0 auto; padding: 24px;
}
.hero {
  padding: 48px 0 40px; text-align: center;
}
.hero h1 {
  font-size: 34px; font-weight: 700;
  letter-spacing: -0.02em; margin-bottom: 12px;
}
.hero p {
  color: var(--text-2); font-size: 15px;
  max-width: 620px; margin: 0 auto;
}
.home-search {
  max-width: 480px; margin: 28px auto 0;
}
.home-search input {
  width: 100%; height: 44px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 15px; font-family: var(--font);
  background: var(--surface); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.home-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.home-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.home-card h3 {
  font-size: 13px; font-weight: 600; color: var(--accent);
  margin-bottom: 12px; letter-spacing: 0.04em;
  text-transform: uppercase;
}
.home-card ul { list-style: none; }
.home-card li { margin-bottom: 2px; }
.home-card a, .home-card span {
  display: block; padding: 4px 8px;
  border-radius: var(--radius-sm); font-size: 13.5px;
  color: var(--text-2); text-decoration: none;
  transition: all 0.12s;
}
.home-card a:hover {
  background: var(--surface-2); color: var(--accent);
}
.home-card span.stub { opacity: 0.5; cursor: default; }

.home-foot {
  text-align: center; padding: 40px 0 24px;
  font-size: 12px; color: var(--text-3);
}

/* ---------- Toast ---------- */
#kb-toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(26, 29, 33, 0.92); color: #fff;
  font-size: 13px; padding: 8px 18px; border-radius: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999; font-family: var(--font);
}
#kb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .page {
    grid-template-columns: 1fr; padding: 16px; gap: 20px;
  }
  .sidebar {
    position: static; max-height: none;
    display: flex; flex-wrap: wrap; gap: 16px;
  }
  .nav-group { margin-bottom: 0; flex: 1 1 140px; }
  .entry { padding: 24px 20px; }
  .entry-title { font-size: 24px; }
  .topbar-inner { padding: 0 16px; gap: 12px; }
  .search-wrap { max-width: none; }
  .hero { padding: 32px 0 24px; }
  .hero h1 { font-size: 26px; }
}