:root {
  --kb-shadow: 0 18px 0 rgba(31, 61, 43, 0.18);
  --kb-line: rgba(122, 74, 40, 0.18);
  --kb-soft: #f7ecd2;
}

.kb-wrap { width: min(1180px, calc(100% - 32px)); }

.kb-hero {
  margin: 18px 0 14px;
  padding: 8px 4px 0;
}

.kb-kicker {
  margin: 0 0 6px;
  color: #f2d99a;
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.kb-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4.6vw, 3.2rem);
  line-height: 1.12;
}

.kb-sub {
  max-width: 46rem;
  margin: 10px 0 0;
  color: #f7eed4;
  opacity: 0.94;
  line-height: 1.7;
}

.kb-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
}

.kb-stats span {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 12px;
  border: 2px solid rgba(216, 181, 106, 0.65);
  border-radius: 999px;
  color: #f7eed4;
  background: rgba(42, 64, 48, 0.52);
  font-size: 0.86rem;
}

.kb-stats b { font-family: "ZCOOL KuaiLe", sans-serif; font-size: 1.15rem; color: #ffe6a8; }

.kb-disclaimer {
  max-width: 52rem;
  margin: 12px 0 0;
  color: #e9ddbd;
  font-size: 0.8rem;
  line-height: 1.65;
}

.kb-shell {
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.kb-index {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 14px;
  border-width: 3px;
  border-radius: 22px;
  overscroll-behavior: contain;
}

.kb-search label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bark);
}

.kb-search input {
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border-width: 2px;
  border-radius: 12px;
  font-size: 15px;
}

.kb-count {
  margin: 8px 0 10px;
  color: var(--bark);
  font-size: 0.78rem;
}

.kb-chapter { margin-bottom: 12px; }

.kb-chapter h3 {
  position: sticky;
  top: -14px;
  z-index: 1;
  margin: 0 0 4px;
  padding: 7px 4px 5px;
  background: var(--paper);
  color: var(--bark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-bottom: 1px dashed var(--kb-line);
}

.kb-chapter h3 small { display: block; font-weight: 400; opacity: 0.72; font-size: 0.7rem; }

.kb-item {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  width: 100%;
  min-height: 40px;
  margin: 2px 0;
  padding: 7px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.42;
  text-align: left;
}

.kb-item:hover { background: var(--kb-soft); filter: none; }
.kb-item.on { background: var(--moss); color: #f7eed4; }
.kb-item .n { flex: 0 0 auto; color: var(--bark); font-weight: 700; }
.kb-item.on .n { color: #ffe6a8; }
.kb-item .lvl { flex: 0 0 auto; margin-left: auto; font-size: 0.66rem; opacity: 0.8; }

.kb-main { min-width: 0; }

.kb-card { padding: 22px 24px 20px; }

.kb-crumb {
  margin: 0 0 4px;
  color: var(--bark);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.kb-card h2 {
  margin: 0;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  line-height: 1.25;
}

.kb-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: #e9dfc6;
  color: #4a3726;
}

.tag.t1 { background: #d9ead6; color: #24512d; }
.tag.t2 { background: #f6e4bb; color: #6b4a12; }
.tag.t3 { background: #dbe6f1; color: #224a6b; }
.tag.t4 { background: #f3d4cc; color: #7a2a1c; }

.kb-gist {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-left: 4px solid var(--gold);
  border-radius: 0 12px 12px 0;
  background: var(--kb-soft);
  line-height: 1.75;
  color: #3a2a1d;
}

.kb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 14px 0 6px;
}

.kb-actions button { min-height: 40px; padding: 7px 13px; border-width: 2px; border-radius: 12px; font-size: 0.9rem; }
.kb-actions .primary { background: var(--moss); color: #f7eed4; }
.kb-actions .ghost { background: #fffdf8; }
.kb-gen-note { color: var(--bark); font-size: 0.76rem; }

.chart-stage { margin: 10px 0 4px; }

.pillar-table {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.pillar-col {
  min-width: 0;
  padding: 9px 5px 8px;
  border: 2px solid var(--gold);
  border-radius: 14px;
  background: #fffdf8;
  text-align: center;
}

.pillar-col .p-label { color: var(--bark); font-size: 0.72rem; }
.pillar-col .p-god { min-height: 1.2em; font-size: 0.78rem; color: #6a4a2a; }
.pillar-col .p-stem, .pillar-col .p-branch {
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: clamp(1.7rem, 3.4vw, 2.35rem);
  line-height: 1.08;
}
.pillar-col .p-stem { margin-top: 2px; }
.pillar-col .p-hidden {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed var(--kb-line);
  color: #5c4430;
  font-size: 0.7rem;
  line-height: 1.55;
}
.pillar-col .p-hidden span { display: block; white-space: nowrap; }
.pillar-col .p-palace { margin-top: 5px; color: #8a6a4a; font-size: 0.66rem; }

.el-木 { color: #2f6b3d; }
.el-火 { color: #a3341f; }
.el-土 { color: #7b5320; }
.el-金 { color: #8a6b12; }
.el-水 { color: #1f4f76; }

.chart-facts, .relation-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.chart-facts span, .relation-strip span {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--kb-soft);
  color: #4a3726;
  font-size: 0.74rem;
}

.relation-strip span.rel { background: #e8eef6; color: #224a6b; }
.relation-strip span.hit { background: #f6e4bb; color: #6b4a12; }

.kb-readout { margin: 16px 0 0; }

.kb-section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 1.12rem;
}

.kb-section-title small { font-family: inherit; font-size: 0.72rem; color: var(--bark); font-weight: 400; }

.kb-readout ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.kb-readout li {
  position: relative;
  margin: 7px 0;
  padding: 9px 12px 9px 40px;
  border-radius: 12px;
  background: #fbf3df;
  line-height: 1.72;
  font-size: 0.92rem;
}

.kb-readout li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 10px;
  top: 9px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--moss);
  color: #f7eed4;
  font-size: 0.72rem;
  line-height: 21px;
  text-align: center;
}

.kb-points {
  margin: 14px 0 0;
  padding: 8px 12px;
  border: 1px dashed var(--kb-line);
  border-radius: 14px;
  background: #fdf7e9;
}

.kb-points summary { font-size: 0.88rem; }

.kb-point {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-top: 1px dashed var(--kb-line);
  font-size: 0.84rem;
  line-height: 1.62;
}

.kb-point:first-of-type { border-top: 0; }
.kb-point .basis { color: var(--bark); font-size: 0.78rem; }
.kb-point .basis b { color: #5a3a20; font-weight: 600; }

.kb-boundary {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f1e7d1;
  color: #5a4632;
  font-size: 0.82rem;
  line-height: 1.68;
}

.kb-boundary b { color: #7a2a1c; }

.kb-pager {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 16px 0 0;
}

.kb-pager button { min-height: 40px; border-width: 2px; border-radius: 12px; background: #fffdf8; font-size: 0.84rem; }
.kb-pager button:last-child { margin-left: auto; }

.kb-empty { padding: 18px; color: var(--bark); }

@media (max-width: 900px) {
  .kb-shell { grid-template-columns: 1fr; }
  .kb-index { position: static; max-height: 340px; }
  .kb-chapter h3 { position: static; }
}

@media (max-width: 560px) {
  .kb-wrap { width: calc(100% - 20px); }
  .kb-card { padding: 16px 14px; }
  .pillar-table { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pillar-col .p-stem, .pillar-col .p-branch { font-size: 2rem; }
  .kb-actions button { flex: 1 1 45%; }
  .kb-readout li { font-size: 0.86rem; }
}

@media (max-width: 390px) {
  .pillar-table { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .pillar-col { padding: 7px 4px; }
  .pillar-col .p-stem, .pillar-col .p-branch { font-size: 1.8rem; }
}


.kb-wrap .module-switch { grid-template-columns: repeat(5, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .kb-wrap .module-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .kb-wrap .module-switch { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


.kb-to-index {
  position: fixed;
  right: 14px;
  bottom: 16px;
  z-index: 60;
  min-height: 42px;
  padding: 8px 14px;
  border: 2px solid var(--gold);
  border-radius: 999px;
  background: var(--moss);
  color: #f7eed4;
  font-size: 0.86rem;
  box-shadow: 0 8px 18px rgba(20, 40, 28, 0.28);
}

@media (min-width: 901px) {
  .kb-to-index { display: none !important; }
}


.kb-howto {
  max-width: 52rem;
  margin: 12px 0 0;
  padding: 8px 12px;
  border: 1px dashed rgba(216, 181, 106, 0.6);
  border-radius: 12px;
  color: #f7eed4;
  background: rgba(42, 64, 48, 0.36);
  font-size: 0.86rem;
  line-height: 1.65;
}

.kb-howto b { color: #ffe6a8; margin-right: 6px; }


.kb-gate {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0 0 10px;
  padding: 9px 10px;
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: var(--kb-soft);
  color: var(--ink);
  text-decoration: none;
}
.kb-gate:hover { background: #fff1cc; filter: none; }
.kb-gate .n { color: #8a5a12; }
.kb-gate .lvl { color: #8a5a12; }

.kb-howto a { color: #ffe6a8; font-weight: 700; }
