:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-grad: linear-gradient(135deg, #4f46e5, #7c3aed);
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 20px 50px -20px rgba(15, 23, 42, .25);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, .82);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 20px;
  height: 64px; display: flex; align-items: center; gap: 14px;
}
.logo { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--brand-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .5);
}
.topbar-spacer { flex: 1; }
.lock-chip, .btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 9px 16px; font-size: .92rem; font-weight: 600;
  transition: .15s;
}
.lock-chip { background: #f1f5f9; color: var(--ink-2); }
.lock-chip.on { background: #ecfdf5; color: var(--green); }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .55); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: #fff; color: var(--ink-2); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--brand); border-color: #c7d2fe; }
.btn-danger { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn-admin { background: #fff; color: var(--ink-2); border: 1px solid var(--line); }
.btn-admin:hover { color: var(--ink); border-color: var(--ink-3); }

/* ---------- 主容器 ---------- */
.wrap { max-width: 1160px; margin: 0 auto; padding: 24px 20px 80px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: .92rem; margin-bottom: 18px; flex-wrap: wrap; }
.breadcrumb a { color: var(--ink-2); }
.breadcrumb a:hover { color: var(--brand); }
.back-btn { cursor: pointer; color: var(--ink-2); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.back-btn:hover { color: var(--brand); }

/* ---------- Hero / 首页 ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 24px; color: #fff; padding: 56px 44px;
  background:
    radial-gradient(900px 300px at 85% -10%, rgba(167, 139, 250, .55), transparent 60%),
    radial-gradient(700px 260px at 0% 110%, rgba(34, 211, 238, .35), transparent 55%),
    linear-gradient(120deg, #312e81 0%, #4f46e5 45%, #6d28d9 100%);
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ""; position: absolute; right: -70px; top: -70px; width: 260px; height: 260px;
  border: 34px solid rgba(255, 255, 255, .08); border-radius: 50%;
}
.hero h1 { margin: 0 0 10px; font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: 1px; }
.hero p { margin: 0; opacity: .9; max-width: 640px; font-size: 1.02rem; }
.hero-stats { display: flex; gap: 34px; margin-top: 30px; flex-wrap: wrap; }
.stat b { font-size: 1.6rem; display: block; line-height: 1.2; }
.stat span { font-size: .86rem; opacity: .82; }
.search-box {
  margin-top: 26px; display: flex; gap: 8px; max-width: 520px;
}
.search-box input {
  flex: 1; border: 0; border-radius: 12px; padding: 13px 18px; font-size: .96rem;
  background: rgba(255, 255, 255, .95); color: var(--ink); outline: none;
}
.search-box input:focus { box-shadow: 0 0 0 3px rgba(199, 210, 254, .7); }
.search-box .btn { background: #fff; color: var(--brand); }
.search-box .btn:hover { color: var(--brand-2); }

/* ---------- 区块标题 ---------- */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 40px 4px 16px; gap: 12px; flex-wrap: wrap; }
.sec-title { font-size: 1.35rem; font-weight: 800; }
.sec-title small { color: var(--ink-3); font-weight: 500; font-size: .9rem; margin-left: 10px; }

/* ---------- 栏目卡片 ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.cat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; cursor: pointer; position: relative; overflow: hidden;
  transition: transform .16s, box-shadow .16s;
}
.cat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.cat-card .tint { position: absolute; inset: 0 0 auto 0; height: 96px; opacity: .16; }
.cat-card .ico {
  width: 54px; height: 54px; border-radius: 15px; display: flex; align-items: center; justify-content: center;
  font-size: 27px; background: #fff; box-shadow: var(--shadow); position: relative;
}
.cat-card h3 { margin: 14px 0 6px; font-size: 1.12rem; position: relative; }
.cat-card p { margin: 0; color: var(--ink-2); font-size: .88rem; position: relative; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat-meta { display: flex; gap: 12px; color: var(--ink-3); font-size: .82rem; margin-top: 14px; position: relative; }
.empty-cats { grid-column: 1 / -1; text-align: center; color: var(--ink-3); padding: 40px 0; }

/* ---------- 内容卡片 ---------- */
.entry-list { display: flex; flex-direction: column; gap: 14px; }
.entry-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; cursor: pointer; transition: box-shadow .16s, transform .16s;
}
.entry-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.entry-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.badge-cat { background: #eef2ff; color: #4338ca; }
.badge-lock { background: #fef3c7; color: #92400e; }
.badge-file { background: #ecfeff; color: #0e7490; }
.entry-card h3 { margin: 2px 0 6px; font-size: 1.08rem; color: var(--ink); }
.entry-card p { margin: 0; color: var(--ink-2); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry-foot { margin-top: 12px; color: var(--ink-3); font-size: .82rem; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dots { text-align: center; color: var(--ink-3); padding: 30px 0; }

/* ---------- 详情视图 ---------- */
.detail-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 30px 32px; box-shadow: var(--shadow);
}
.detail-card h1 { margin: 4px 0 8px; font-size: 1.55rem; line-height: 1.4; }
.detail-card .abs { color: var(--ink-2); font-size: .98rem; border-left: 4px solid #c7d2fe; padding-left: 14px; margin: 6px 0 0; }
.detail-meta { display: flex; gap: 16px; color: var(--ink-3); font-size: .86rem; flex-wrap: wrap; margin-top: 12px; }

/* 解锁提示条 */
.unlock-hint {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(120deg, #fefce8, #fffbeb); border: 1px dashed #fbbf24;
  border-radius: 16px; padding: 18px 20px; margin-top: 20px;
}
.unlock-hint .txt { flex: 1; min-width: 220px; }
.unlock-hint b { color: #92400e; }
.unlock-hint .sub { font-size: .85rem; color: #a16207; }

/* 正文区 */
.kb-content { margin-top: 24px; font-size: .99rem; color: #1e293b; word-break: break-word; }
.kb-content h1, .kb-content h2, .kb-content h3, .kb-content h4 { margin: 22px 0 10px; line-height: 1.4; }
.kb-content h2 { font-size: 1.3rem; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.kb-content h3 { font-size: 1.12rem; }
.kb-content p { margin: 10px 0; }
.kb-content ul, .kb-content ol { padding-left: 24px; margin: 10px 0; }
.kb-content li { margin: 4px 0; }
.kb-content blockquote { margin: 12px 0; padding: 10px 16px; background: #f8fafc; border-left: 4px solid #c7d2fe; border-radius: 6px; color: var(--ink-2); }
.kb-content hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.kb-content a { text-decoration: underline; }
.kb-content strong { font-weight: 700; }
.kb-content code { background: #f1f5f9; padding: 2px 7px; border-radius: 6px; font-size: .9em; }
.kb-content img { max-width: 100%; border-radius: 12px; }

/* 文件区 */
.file-sec-title { margin: 34px 0 14px; font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.file-list { display: flex; flex-direction: column; gap: 12px; }
.file-item {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: #fbfcfe;
}
.file-item:hover { border-color: #c7d2fe; }
.file-ico {
  width: 46px; height: 46px; border-radius: 12px; font-size: 23px;
  display: flex; align-items: center; justify-content: center; background: #eef2ff; flex: 0 0 auto;
}
.file-main { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: .95rem; word-break: break-all; }
.file-sub { font-size: .8rem; color: var(--ink-3); }
.file-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-lock { font-size: .75rem; color: #b45309; font-weight: 700; margin-left: 8px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 23, 42, .5); backdrop-filter: blur(6px);
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%; max-width: 460px; background: #fff; border-radius: 20px;
  padding: 26px; box-shadow: var(--shadow-lg); animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { margin: 0 0 6px; font-size: 1.2rem; }
.modal .sub { color: var(--ink-2); font-size: .9rem; margin-bottom: 16px; }
.modal input[type=password] {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 1rem; outline: none; margin-bottom: 6px;
}
.modal input[type=password]:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.modal-err { color: var(--red); font-size: .86rem; min-height: 20px; margin: 4px 0 8px; }
.modal-acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.close-x { float: right; border: 0; background: transparent; font-size: 1.3rem; color: var(--ink-3); cursor: pointer; line-height: 1; }

/* 预览层 */
.preview-mask {
  position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(2, 6, 23, .88);
}
.preview-mask.show { display: flex; }
.preview-box { width: 100%; height: 100%; max-width: 1200px; max-height: 96vh; background: #fff; border-radius: 14px; overflow: hidden; position: relative; display: flex; flex-direction: column; }
.preview-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.preview-head b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.preview-head button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 14px; cursor: pointer; }
.preview-body { flex: 1; overflow: auto; background: #0f172a; display: flex; align-items: center; justify-content: center; }
.preview-body img { max-width: 100%; max-height: 100%; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-body .no-preview { color: #cbd5e1; text-align: center; padding: 40px; }
.preview-body .no-preview .big { font-size: 2rem; }

/* 提示 Toast */
#toast { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .25s; z-index: 300; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast .toast-in { background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow-lg); }
#toast.err .toast-in { background: var(--red); }

/* ---------- 页脚 ---------- */
.footer { border-top: 1px solid var(--line); background: #fff; margin-top: 40px; }
.footer-in { max-width: 1160px; margin: 0 auto; padding: 26px 20px; color: var(--ink-3); font-size: .86rem; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .hero { padding: 36px 24px; }
  .detail-card { padding: 20px 18px; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); }
}

/* ---------- 子栏目（二级栏目） ---------- */
.badge-sub { background: #f0f4ff; color: #4f46e5; }

/* ---------- 嵌入模式（供官网 iframe 使用） ---------- */
body.kb-embed .topbar { display: none; }
body.kb-embed .footer { display: none; }
body.kb-embed .wrap { padding-top: 18px; padding-bottom: 30px; }
body.kb-embed .hero { padding: 34px 30px; border-radius: 18px; }
/* 子栏目页面包屑（子栏目为当前页，稍加重显示） */
.breadcrumb .crumb-sub { color: #4338ca; font-weight: 700; }
/* 子栏目首页区块加一点下间距 */
.cat-grid .cat-card .ico.file { background: linear-gradient(135deg, #eef2ff, #e0e7ff); }
