:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #5b6675;
  --line: #e3e8f0;
  --brand: #2f5cff;
  --brand-soft: #eaf0ff;
  --accent: #0aa06e;
  --warn: #d9822b;
  --danger: #d64545;
  --hl: #fff3bf;
  --hl-border: #f2c94c;
  --shadow: 0 6px 24px rgba(28, 42, 82, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.75;
  font-size: 16px;
}

a { color: var(--brand); }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #7aa0ff);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .tools { display: flex; gap: 10px; align-items: center; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #1f49e0; color: #fff; }

/* ---------- 布局 ---------- */
.layout { display: flex; gap: 26px; max-width: 1180px; margin: 0 auto; padding: 26px 22px 90px; }
.toc {
  position: sticky;
  top: 72px;
  align-self: flex-start;
  width: 240px;
  flex: 0 0 240px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
}
.toc h4 { margin: 4px 6px 10px; color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.toc a {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 2px;
}
.toc a:hover { background: var(--brand-soft); }
.toc a.active { background: var(--brand); color: #fff; }

.content { flex: 1; min-width: 0; }

/* ---------- 文章排版 ---------- */
.hero {
  background: linear-gradient(135deg, #23305c, #2f5cff);
  color: #fff;
  border-radius: 18px;
  padding: 34px 36px;
  margin-bottom: 26px;
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 8px; font-size: 30px; }
.hero p { margin: 0; opacity: 0.92; font-size: 15px; }

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 30px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  scroll-margin-top: 78px;
}
.section > h2 {
  margin: 0 0 6px;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section > h2 .num {
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 700;
}
.section h3 { font-size: 17px; margin: 22px 0 8px; color: #22324f; }
.section p { margin: 10px 0; }
.lead { color: var(--muted); font-size: 15px; margin-top: 0; }

.plain {
  background: #f0f9f4;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 14px 0;
}
.plain b { color: var(--accent); }

.note {
  background: #fff8ec;
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 14px 0;
}

.formula {
  background: #0f172a;
  color: #e6edf7;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 14px 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 15px;
  overflow-x: auto;
  line-height: 1.9;
}
.formula .op { color: #7ee787; }
.formula .var { color: #ffa657; }
.formula .cm { color: #8b98a8; }

.example {
  border: 1px dashed var(--brand);
  background: var(--brand-soft);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 14px 0;
}
.example .tag {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
  overflow: hidden;
  border-radius: 10px;
}
table.grid th, table.grid td {
  border: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
}
table.grid th { background: #f2f5fb; font-weight: 700; }
table.grid tr:nth-child(even) td { background: #fafbfe; }
table.grid td.center, table.grid th.center { text-align: center; }
.yes { color: var(--accent); font-weight: 700; }
.no { color: #b7bfca; }
.total-row td { background: #eef3ff !important; font-weight: 800; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 1px 9px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
}
.badge.cfg { color: var(--brand); border-color: #bcccff; background: var(--brand-soft); }
.badge.fixed { color: var(--muted); }

.cfg-key {
  font-family: Consolas, Menlo, monospace;
  background: #eef1f6;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 13px;
  color: #334;
}

/* 图 */
.diagram { text-align: center; margin: 18px 0; }
.mermaid { display: flex; justify-content: center; }

.flowrow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
  margin: 16px 0;
}
.flowrow .node {
  flex: 1;
  min-width: 120px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  box-shadow: var(--shadow);
}
.flowrow .node b { display: block; margin-bottom: 4px; }
.flowrow .arrow { display: flex; align-items: center; color: var(--brand); font-size: 20px; }

/* 角色卡片（站点B） */
.rolecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin: 16px 0; }
.rolecard {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  background: #fff;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--brand);
}
.rolecard h3 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.rolecard .lvl { font-size: 12px; color: #fff; background: var(--brand); border-radius: 20px; padding: 1px 9px; }
.rolecard .scope { font-size: 13px; color: var(--muted); margin: 6px 0 10px; }
.rolecard ul { margin: 8px 0; padding-left: 18px; }
.rolecard ul li { margin: 3px 0; font-size: 14px; }
.rolecard.director { border-top-color: #d64545; }
.rolecard.director .lvl { background: #d64545; }
.rolecard.major { border-top-color: #d9822b; }
.rolecard.major .lvl { background: #d9822b; }
.rolecard.share { border-top-color: #caa80a; }
.rolecard.share .lvl { background: #caa80a; }
.rolecard.gagent { border-top-color: #0aa06e; }
.rolecard.gagent .lvl { background: #0aa06e; }
.rolecard.agent { border-top-color: #2f5cff; }
.rolecard.agent .lvl { background: #2f5cff; }
.rolecard.member { border-top-color: #7a52c7; }
.rolecard.member .lvl { background: #7a52c7; }
.rolecard.sub { border-top-color: #5b6675; }
.rolecard.sub .lvl { background: #5b6675; }

/* ---------- 批注高亮 & 建议栏 ---------- */
.nx-hl {
  background: var(--hl);
  border-bottom: 2px solid var(--hl-border);
  border-radius: 3px;
  cursor: pointer;
  padding: 0 1px;
}
.nx-pin {
  display: inline-block;
  min-width: 16px; height: 16px;
  line-height: 16px;
  font-size: 10px;
  text-align: center;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  vertical-align: super;
  margin-left: 2px;
  cursor: pointer;
}

/* 选中弹出"提建议"按钮 */
#nx-selbtn {
  position: absolute;
  z-index: 999;
  display: none;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(47, 92, 255, 0.4);
}
#nx-selbtn::after { content: ""; }

/* 建议侧栏 */
#nx-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 30px rgba(20, 30, 60, 0.12);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}
#nx-panel.open { transform: translateX(0); }
#nx-panel header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
#nx-panel header b { font-size: 16px; }
#nx-panel header .spacer { flex: 1; }
#nx-panel .body { flex: 1; overflow: auto; padding: 14px 16px; }
#nx-panel .foot { border-top: 1px solid var(--line); padding: 12px 16px; }

.nx-form textarea {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.nx-form input[type=text] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  margin-top: 8px;
}
.nx-quote {
  background: var(--hl);
  border-left: 3px solid var(--hl-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: #555;
  margin-bottom: 10px;
  max-height: 120px;
  overflow: auto;
}
.nx-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 14px;
}
.nx-item .meta { color: var(--muted); font-size: 12px; margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nx-item .sec { color: var(--brand); font-size: 12px; }
.nx-item .q { color: #777; font-size: 12px; border-left: 2px solid var(--hl-border); padding-left: 6px; margin: 4px 0; }
.nx-item.resolved { opacity: 0.55; }
.nx-empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 14px; }

.nx-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 900;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 30px;
  padding: 12px 18px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(47, 92, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nx-fab .cnt {
  background: #fff;
  color: var(--brand);
  border-radius: 20px;
  font-size: 12px;
  padding: 0 7px;
  font-weight: 700;
}

/* 登录页 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1c2545, #2f5cff);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 38px 34px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.login-card h1 { margin: 6px 0 2px; font-size: 22px; }
.login-card p { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  text-align: center;
  letter-spacing: 3px;
}
.login-card button {
  width: 100%;
  margin-top: 14px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  cursor: pointer;
}
.login-card .err { color: var(--danger); font-size: 13px; height: 18px; margin-top: 10px; }
.login-logo {
  width: 54px; height: 54px; border-radius: 16px;
  margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--brand), #7aa0ff);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 26px; font-weight: 800;
}

@media (max-width: 860px) {
  .toc { display: none; }
  .layout { padding: 16px 12px 90px; }
  .section { padding: 18px 16px; }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 23px; }
}
