/* Reference-style interactive result panels. */
.has-chart .result-card > .four-pillars-graph,
.has-chart .result-card > .source-library { margin: 14px; }
.graph-tabs button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  padding: 13px 4px;
  color: #777;
  font: 12px "Noto Sans SC", sans-serif;
}
.graph-tabs button:last-child { border-right: 0; }
.graph-tabs button.is-active { color: #9c7a36; background: #f8f3e9; font-weight: 600; }
.graph-panel { display: none; }
.graph-panel.is-active { display: block; }
.reference-ganzhi-layout { width: min(100%, 680px); min-height: 410px; margin: 0 auto; padding: 18px 0 26px; }
.relation-layer { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: row; row-gap: 8px; }
.gan-layer { min-height: 58px; margin-bottom: 24px; }
.zhi-layer { min-height: 150px; margin-top: 25px; }
.relation-track { min-width: 0; }
.relation-track .edge-path { width: 100%; }
.relation-track .edge-line { max-width: none; }
.relation-track > small { display: none; }
.reference-ganzhi-layout .graph-pillars { width: 100%; max-width: none; margin: 0; }
.reference-ganzhi-layout .graph-pillars div { gap: 9px; }
.reference-ganzhi-layout .graph-pillars b,
.reference-ganzhi-layout .graph-pillars strong { font-size: 29px; }
.graph-empty { margin: 32px 0; color: #999; text-align: center; }
.graph-edge { display: grid; grid-template-columns: 1fr; gap: 4px; }
.graph-edge::before { display: none; }
.edge-path { position: relative; display: flex; align-items: center; justify-content: center; min-height: 34px; }
.edge-path i { flex: none; }
.edge-line { flex: 1; max-width: 110px; min-width: 28px; border-top: 1px solid #cfd1d3; }
.edge-path b { position: absolute; top: 50%; left: 50%; z-index: 2; padding: 1px 8px; transform: translate(-50%, -50%); background: #fff; color: #666; font-size: 11px; font-weight: 500; white-space: nowrap; }
.graph-edge.combine .edge-path b { color: #957529; }
.graph-edge.clash .edge-path b { color: #a05b53; }
.graph-edge.restrain .edge-path b { color: #ad584e; }
.graph-edge small { grid-column: auto; text-align: center; }
.graph-info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; max-width: 850px; margin: 24px auto; }
.graph-info-grid article { min-height: 185px; padding: 18px 12px; border: 1px solid #eee; border-radius: 8px; background: #fff; text-align: center; }
.graph-info-grid small { color: #aaa; font-size: 11px; }
.mini-pillar { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 18px 0 13px; }
.mini-pillar b, .mini-pillar strong { font: 500 27px "Noto Serif SC", serif; }
.mini-pillar i { color: #c1c1c1; font-size: 12px; font-style: normal; }
.graph-info-grid h4 { margin: 10px 0 8px; color: #555; font-size: 13px; }
.graph-info-grid p { margin: 0; color: #888; font-size: 11px; line-height: 1.7; }
.graph-info-grid span { display: inline-block; margin-top: 8px; color: #a98a4e; font-size: 11px; }
.palace-grid article, .family-grid article { min-height: 205px; }

/* Flow view: directional five-element network. */
.flow-panel { min-height: 430px; padding-top: 24px; }
.flow-chart { width: min(100%, 640px); margin: 0 auto; }
.flow-row { display: grid; grid-template-columns: minmax(66px, 1fr) 96px minmax(66px, 1fr) 96px minmax(66px, 1fr) 96px minmax(66px, 1fr); align-items: center; }
.flow-pillar { min-width: 0; text-align: center; }
.flow-pillar small { display: block; min-height: 20px; color: #aaa; font-size: 11px; }
.flow-pillar b, .flow-pillar strong { display: block; margin: 5px 0; font: 500 25px "Noto Serif SC", serif; }
.flow-pillar em { display: block; min-height: 18px; margin-top: 22px; color: #b59a61; font-size: 11px; font-style: normal; }
.flow-horizontal { position: relative; display: flex; align-items: center; justify-content: center; height: 34px; color: #42934b; border-top: 1px solid currentColor; border-bottom: 1px solid currentColor; }
.flow-horizontal span { font-size: 20px; line-height: 1; }
.flow-horizontal b, .flow-vertical b { display: grid; z-index: 1; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; background: #49954f; font-size: 11px; }
.flow-horizontal.left .right-arrow, .flow-horizontal.right .left-arrow { opacity: .15; }
.flow-horizontal.both span { opacity: .85; }
.flow-horizontal.block { border-color: transparent; color: #ef302b; }
.flow-horizontal.block span { visibility: hidden; }
.flow-horizontal.block b { background: #ef302b; }
.flow-horizontal.support { border-style: double; }
.flow-vertical-row { min-height: 96px; }
.flow-vertical-row > i { display: block; }
.flow-vertical { position: relative; justify-self: center; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 25px; height: 96px; color: #42934b; border-left: 1px solid currentColor; border-right: 1px solid currentColor; }
.flow-vertical span { font-size: 20px; line-height: 1; }
.flow-vertical.up .down-arrow, .flow-vertical.down .up-arrow { opacity: .18; }
.flow-vertical.block { border-color: transparent; color: #ef302b; }
.flow-vertical.block span { visibility: hidden; }
.flow-vertical.block b { background: #ef302b; }
.flow-legend { width: min(100%, 640px); margin: 24px auto 0; }
.flow-legend p { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: #444; font-size: 12px; }
.flow-legend i { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; font-style: normal; }
.flow-legend .pass { background: #049e40; }.flow-legend .stop { background: #f00000; }

/* Palace view: four pillars over a four-layer imagery matrix. */
.palace-panel { min-height: 620px; padding-top: 38px; }
.palace-pillars { display: grid; grid-template-columns: repeat(4, 1fr); width: min(100%, 620px); margin: 0 auto 34px; text-align: center; }
.palace-pillars article { display: flex; flex-direction: column; align-items: center; }
.palace-title { display: flex; flex-direction: column; justify-content: end; min-height: 76px; margin-bottom: 5px; color: #333; font-size: 12px; line-height: 1.85; }
.palace-pillars small { color: #aaa; font-size: 11px; }
.palace-pillars b, .palace-pillars strong { margin-top: 8px; font: 500 25px "Noto Serif SC", serif; }
.palace-matrix { width: min(100%, 620px); margin: 0 auto; overflow: hidden; border: 1px solid #ececec; border-radius: 28px; background: #fff; }
.palace-matrix section { padding: 15px 18px; border-bottom: 1px solid #eee; }
.palace-matrix section:last-child { border-bottom: 0; }
.palace-matrix h4 { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 12px; color: #444; font-size: 12px; }
.palace-matrix h4 i { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; background: #b89a5d; font-style: normal; }
.palace-matrix section > div { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.palace-matrix p { margin: 0; color: #444; font-size: 11px; line-height: 1.7; }
.palace-matrix p span { color: #555; }

/* Family view: parallel relative and social relation tables. */
.family-panel { min-height: 480px; padding: 0; }
.family-relations { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 900px; }
.family-relations > section:first-child { border-right: 1px solid #ddd; }
.family-relations > section > h4 { margin: 0; padding: 12px; border-bottom: 1px solid #ddd; text-align: center; font-size: 13px; }
.family-columns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.family-columns article { display: flex; flex-direction: column; align-items: center; min-height: 392px; padding: 26px 8px 18px; text-align: center; }
.role-list { display: flex; flex-direction: column; justify-content: end; min-height: 78px; margin-bottom: 8px; color: #333; font-size: 11px; line-height: 1.8; }
.role-list.lower { justify-content: start; min-height: 86px; margin: 9px 0 0; }
.family-columns small { color: #aaa; font-size: 11px; }
.family-columns b, .family-columns strong { margin: 7px 0 0; font: 500 24px "Noto Serif SC", serif; }
.family-columns strong { margin-bottom: 7px; }
.graph-panel > footer { margin: 24px -8% -20px; }
.source-tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.source-tabs button { flex: 0 0 auto; appearance: none; border: 0; border-right: 1px solid #f0f0f0; background: #fff; cursor: pointer; padding: 13px 18px; color: #777; font: 12px "Noto Sans SC", sans-serif; white-space: nowrap; }
.source-tabs button.is-active { color: #9b7931; background: #faf6ed; font-weight: 600; }
.source-deck { min-height: 180px; background: #fff; }
.source-deck .source-card { display: none; padding: 24px; }
.source-deck .source-card.is-active { display: flex; }
.source-meta > header { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 13px; }
.source-meta > header h4 { margin: 0 0 7px; font-size: 16px; }
.source-meta > header p { margin: 0; color: #888; font-size: 12px; line-height: 1.7; }
.source-meta > header em { flex: none; border-radius: 99px; padding: 4px 9px; color: #9b7931; background: #f8f3e7; font-size: 11px; font-style: normal; }
.source-deck .detail-lines { margin-top: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.source-deck .detail-lines p { border-left: 2px solid #dfd1ae; border-radius: 0 6px 6px 0; }
.reading-panel-copy { display: none; }
.reading-panel-copy.is-active { display: block; }
.reading-element-bars { display: grid; gap: 12px; margin-top: 18px; }
.reading-element-bars > div { display: grid; grid-template-columns: 22px 1fr 24px; align-items: center; gap: 9px; }
.reading-element-bars b, .reading-element-bars em { font-size: 11px; font-style: normal; }
.reading-element-bars i { height: 7px; overflow: hidden; border-radius: 99px; background: #f1f1f1; }
.reading-element-bars span { display: block; height: 100%; border-radius: 99px; }
.reading-element-bars .fire { background: var(--fire); }.reading-element-bars .water { background: var(--water); }.reading-element-bars .wood { background: var(--wood); }.reading-element-bars .earth { background: var(--earth); }.reading-element-bars .metal { background: var(--metal); }
.reading-panel-copy small { color: #aaa; }

@media (max-width: 720px) {
  .graph-canvas { padding: 18px 12px; }
  .reference-ganzhi-layout { min-width: 560px; }
  .ganzhi-panel { overflow-x: auto; }
  .graph-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 8px auto; }
  .source-deck .detail-lines { grid-template-columns: 1fr; }
  .source-deck .source-card { padding: 18px 14px; }
  .source-meta > header { flex-direction: column; gap: 8px; }
  .flow-panel, .palace-panel, .family-panel { overflow-x: auto; }
  .flow-chart, .flow-legend { min-width: 610px; }
  .palace-pillars, .palace-matrix { min-width: 600px; }
}

@media (max-width: 430px) {
  .graph-info-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .graph-info-grid article { min-height: 160px; padding: 14px 8px; }
  .graph-tabs button { font-size: 11px; }
  .source-tabs button { padding: 11px 13px; }
}
