/* 南阳李族神子 · 页面样式（与 genealogy-tree / orgchart-li-family 视觉一致） */
:root {
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --line: #c9b896;
  --panel: #faf7f0;
  --accent: #6b4c2a;
  --gap: #8b4513;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "Microsoft YaHei", Georgia, serif;
  color: var(--ink);
  background: linear-gradient(165deg, #f5efe4 0%, #ebe4d6 100%);
  min-height: 100vh;
  line-height: 1.55;
}
header.app-hd {
  padding: 1.5rem 1rem 1.1rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}
header.app-hd h1 {
  margin: 0 0 0.35rem;
  font-size: 1.42rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--accent);
}
header.app-hd p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}
.poem {
  max-width: 36rem;
  margin: 0.85rem auto 0;
  padding: 0.65rem 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--panel);
}
main.app-main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1rem 0.85rem 2.5rem;
}
section.card {
  margin-bottom: 1.25rem;
  background: #fffef9;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(44, 36, 22, 0.06);
}
section.card > h2 {
  margin: 0;
  padding: 0.6rem 0.95rem;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(90deg, #e8dcc8, #f5efe4);
  color: var(--accent);
  border-bottom: 1px solid var(--line);
}
.card-body { padding: 0.75rem 0.9rem 1rem; }

/* OrgChart 节点配色 */
.orgchart { background: #f7f7f7; }
.orgchart td.left, .orgchart td.right, .orgchart td.top { border-color: #bdbdbd; }
.orgchart td > .down { background-color: #bdbdbd; }
.fc-gen1 .title { background-color: #c5ccd4; color: #3d4550; }
.fc-gen1 .content { border-color: #b0b8c2; color: #4a4a4a; }
.fc-gen2 .title { background-color: #c8d0c8; color: #3d453d; }
.fc-gen2 .content { border-color: #b5bdb5; color: #4a4a4a; }
.fc-root .title { background-color: #cfcfcf; color: #454545; }
.fc-root .content { border-color: #bfbfbf; color: #4a4a4a; }
.fc-node .title { background-color: #c9ced4; color: #3d4450; }
.fc-node .content { border-color: #b8bec6; color: #4a4a4a; }
.orgchart .node { padding: 6px 10px; }
.orgchart .node .title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.35;
}
.orgchart .node .title .rank-box {
  display: inline-block;
  font-size: 0.68em;
  font-weight: 600;
  line-height: 1.15;
  padding: 2px 5px;
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-radius: 2px;
  flex-shrink: 0;
}
.orgchart .node.node--dead .title .rank-box { border-color: rgba(0, 0, 0, 0.22); }
.orgchart .node .avatar {
  display: block;
  margin: 0 auto 6px;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  object-fit: cover;
  box-shadow: rgba(0, 0, 0, 0.08) 0 1px 4px;
  background: #ddd;
  border: 1px solid #c5c5c5;
}
.orgchart .node.node--dead .title,
.orgchart .node.node--dead .content {
  background-color: #d5d5d5 !important;
  border-color: #b8b8b8 !important;
  color: #505050 !important;
}
.orgchart .node.node--dead .avatar { filter: grayscale(1); opacity: 0.95; }
.orgchart.branch-from-ancestor > ul.nodes > li.hierarchy > ul.nodes > li.hierarchy::before {
  border-top-style: dashed !important;
  border-top-color: #9a9a9a !important;
}

.chart-wrap--home {
  position: relative;
  height: 300px;
  overflow: hidden;
  text-align: center;
  border-radius: 6px;
  border: 1px solid #dadada;
  background: #f7f7f7;
}
.chart-wrap--home .orgchart { pointer-events: none; }
.chart-wrap--home .orgchart .edge,
.chart-wrap--home .orgchart .toggleBtn { display: none !important; }

.chart-wrap--branch {
  position: relative;
  height: min(72vh, 560px);
  min-height: 320px;
  overflow: hidden;
  text-align: center;
  border-radius: 6px;
  border: 1px solid #dadada;
  background: #f7f7f7;
  touch-action: none;
  -webkit-overflow-scrolling: touch;
}
.chart-wrap--branch .branch-chart-scale-wrap {
  display: inline-block;
  transform-origin: 0 0;
  vertical-align: top;
}
.chart-wrap--branch > .orgchart {
  transform-origin: 0 0;
}
.chart-wrap--branch .branch-chart-scale-wrap > .orgchart {
  transform-origin: 0 0;
}

.branch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.75rem;
}
.branch-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 6px rgba(44, 36, 22, 0.05);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.branch-card:hover,
.branch-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 3px 14px rgba(107, 76, 42, 0.12);
  outline: none;
}
.branch-card-thumb {
  height: 118px;
  overflow: hidden;
  position: relative;
  background: #ece8e0;
  border-bottom: 1px solid #e0dcd4;
}
.branch-card-thumb .branch-source-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.branch-card-cap {
  padding: 0.45rem 0.5rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  line-height: 1.35;
}
.branch-card-cap small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.15rem;
}

.branch-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}
.btn-back {
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  cursor: pointer;
}
.btn-back:hover { background: var(--panel); }
.view-hidden { display: none !important; }
footer.app-ft {
  text-align: center;
  font-size: 0.76rem;
  color: var(--muted);
  padding: 0.85rem 1rem 1.35rem;
  line-height: 1.65;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
}
.app-ft-inner {
  max-width: 40rem;
  margin: 0 auto;
}
.ft-credit {
  margin: 0;
  letter-spacing: 0.04em;
}
.ft-names {
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.06em;
}
footer.app-ft .btn-link {
  font: inherit;
  font-size: inherit;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0 0.15rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
footer.app-ft .btn-link:hover {
  color: var(--gap);
}
footer.app-ft .ft-note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}

/* 祠堂神子 · 全屏看图 */
.citang-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  box-sizing: border-box;
}
.citang-lightbox.view-hidden {
  display: none !important;
}
.citang-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 24, 18, 0.55);
  cursor: pointer;
}
.citang-lightbox-panel {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 52rem);
  width: 100%;
  max-height: 92vh;
  background: #fffef9;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.citang-lightbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #e8dcc8, #f5efe4);
}
.citang-lightbox-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}
.citang-lightbox-close {
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--accent);
  cursor: pointer;
}
.citang-lightbox-close:hover {
  background: #fff;
}
.citang-lightbox-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.4rem 0.35rem;
  flex: 1;
  min-height: 0;
}
.citang-lightbox-body .citang-nav {
  flex-shrink: 0;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}
.citang-lightbox-body .citang-nav:hover:not(:disabled) {
  background: var(--panel);
}
.citang-lightbox-body .citang-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.citang-lightbox-body img {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  max-height: min(72vh, 520px);
  width: auto;
  height: auto;
  object-fit: contain;
  vertical-align: middle;
}
.citang-lightbox-counter {
  margin: 0;
  padding: 0.35rem 0.75rem 0.65rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid #e8e0d4;
  background: #faf8f4;
}
