/* 知识图谱浏览：左目录、中局部图、右详情。窄屏改为上下堆叠。 */

body.page-explore {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.page-explore .top-banner,
body.page-explore .site-header,
body.page-explore .site-footer { flex: none; }
.explore {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr) minmax(270px, 380px);
  grid-template-rows: minmax(0, 1fr);
}
.explore-mobile-bar { display: none; }

.side, .detail, .graph-pane { min-width: 0; min-height: 0; }
.side {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
}
.side-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.side-tools input, .side-tools select { width: 100%; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.count { color: var(--muted); font-size: 0.92rem; }
.list { overflow: auto; flex: 1; padding-bottom: 12px; }

.vol > summary, .chap > summary {
  cursor: pointer;
  padding: 10px 12px;
  min-height: 44px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.vol > summary { position: sticky; top: 0; background: var(--bg-elev); z-index: 1; border-bottom: 1px solid var(--line); }
.chap > summary { font-weight: 700; font-size: 0.95rem; }
.count-pill { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.topic-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: calc(100% - 16px);
  margin: 3px 8px;
  text-align: left;
  gap: 2px;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.15s ease;
}
.topic-item .nm { font-weight: 650; overflow-wrap: anywhere; }
.topic-item .meta { color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.topic-item:hover { background: var(--bg-muted); transform: translateX(2px); }
.topic-item.sel {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
  color: var(--brand-strong);
}

.graph-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.graph-toolbar button { background: var(--bg); }
.depth, .zoom-tools, .seg { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.depth-label { color: var(--muted); font-weight: 800; font-size: 0.92rem; }
.narrow-only, .zoom-ico { display: none; }
.zoom-tools button { display: inline-flex; align-items: center; justify-content: center; }
.depth button.on { background: var(--brand); color: var(--on-brand); border-color: transparent; }
.graph-fold {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 8px 12px;
  background: var(--warn-bg);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}
.graph-fold button { white-space: normal; max-width: 100%; }
.graph-stage { position: relative; flex: 1; min-width: 0; min-height: 280px; display: flex; flex-direction: column; }
#cy { flex: 1; min-height: 280px; width: 100%; }
.graph-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 24px 20px;
}
.graph-empty p { margin: 0; max-width: 36em; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin: 0;
  padding: 8px 12px 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; border: 2px solid transparent; display: inline-block; }
.sw-p { background: var(--node-primary-bg); border-color: var(--node-primary); }
.sw-j { background: var(--node-junior-bg); border-color: var(--node-junior); }
.sw-h { background: var(--node-senior-bg); border-color: var(--node-senior); }
.sw-c { background: var(--node-current-bg); border-color: var(--node-current-border); }
.line-hard, .line-soft { width: 22px; height: 0; border-radius: 0; border: none; border-top: 2px solid var(--edge); background: none; }
.line-soft { border-top-style: dashed; border-top-color: var(--edge-soft); }
.graph-meta { margin: 0; padding: 4px 12px 10px; color: var(--muted); font-size: 0.9rem; }

.detail {
  overflow: auto;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  padding: 16px 16px 24px;
}
.detail h1 { margin: 0 0 6px; font-size: 1.45rem; line-height: 1.28; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.detail h2 { margin: 18px 0 8px; font-size: 1.08rem; }
.detail p { margin: 0.35em 0; overflow-wrap: anywhere; }
.detail-empty h1 { font-size: 1.4rem; }
.alias-note {
  background: var(--warn-bg);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.pills { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
}
.pill-p { background: var(--node-primary-bg); color: var(--node-text); }
.pill-j { background: var(--node-junior-bg); color: var(--node-text); }
.pill-h { background: var(--node-senior-bg); color: var(--node-text); }
.id-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--muted);
}
.diag-btn { margin: 4px 0 8px; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.meta-grid div { background: var(--bg-muted); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.meta-grid .span-2 { grid-column: 1 / -1; }
.meta-grid dt { color: var(--muted); font-size: 0.82rem; }
.meta-grid dd { margin: 0; font-weight: 800; overflow-wrap: anywhere; }
.detail ul.plain { margin: 4px 0 0; padding-left: 1.2em; }
.std { background: var(--bg-muted); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.std p { margin: 0.25em 0; }
.sample-q {
  background: var(--bg-muted);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 10px 12px;
}
.detail details.ans > summary, .rel-row { cursor: pointer; }
.rel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  margin: 0 0 8px;
  background: var(--bg);
}
.rel-name { font-weight: 800; color: var(--brand-strong); }
.rel-where, .why { color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.why { flex: 1 1 100%; font-weight: 500; }
.muted { color: var(--muted); }
.root-reason { color: var(--muted); }

@media (max-width: 900px) {
  body.page-explore { height: auto; min-height: 100dvh; overflow: auto; }
  .explore { display: flex; flex-direction: column; height: auto; }
  .explore-mobile-bar { display: block; padding: 10px 12px 0; }
  .list-toggle { width: 100%; }
  .side { display: none; border-right: none; }
  .side.open { display: flex; max-height: 62vh; border-bottom: 1px solid var(--line); }
  .graph-stage { flex: none; min-height: 0; }
  #cy { height: 420px; flex: none; }
  .detail { border-left: none; border-top: 1px solid var(--line); }
  .graph-toolbar { padding: 8px; }
}

/* 手机宽度：层数和缩放并成一行，页面本身不横向溢出。放不下时可在工具条内横滑。 */
@media (max-width: 640px) {
  .graph-toolbar {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    padding: 6px 8px;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .graph-toolbar::-webkit-scrollbar { height: 0; }
  .depth, .zoom-tools, .seg { flex: none; flex-wrap: nowrap; gap: 0; }
  .depth { gap: 6px; }
  .zoom-tools { gap: 4px; margin-left: auto; }
  .depth-label { font-size: 0.75rem; white-space: nowrap; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }
  .seg { background: transparent; }
  .graph-toolbar .seg button {
    position: relative;
    min-height: 40px;
    margin-left: -1px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: var(--bg);
    font-size: 0.8rem;
    line-height: 1;
    white-space: nowrap;
  }
  .graph-toolbar .seg button:first-child { margin-left: 0; border-radius: 999px 0 0 999px; }
  .graph-toolbar .seg button:last-child { border-radius: 0 999px 999px 0; }
  .graph-toolbar .seg button.on,
  .graph-toolbar .seg button.on:hover {
    z-index: 1;
    background: var(--brand);
    color: var(--on-brand);
    border-color: var(--brand);
  }
  .graph-toolbar .seg button:hover:not(.on) { background: var(--bg-muted); }
  .zoom-label { display: none; }
  .zoom-ico { display: block; width: 18px; height: 18px; }
  .graph-toolbar .zoom-tools button {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 999px;
  }
}

/* 打印单模态框与 A4 纸张排版 */
.print-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.print-modal[hidden] { display: none !important; }
.print-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
}
.print-modal-dialog {
  position: relative;
  z-index: 1;
  background: #ffffff;
  border-radius: 14px;
  max-width: 860px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.print-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-muted);
}
.print-modal-title { font-weight: 750; font-size: 1.08rem; color: var(--text); }
.print-sheet-content {
  overflow-y: auto;
  padding: 28px 36px;
  color: #1e293b;
  font-family: var(--font);
}

/* 纸单内部布局 */
.sheet-header {
  text-align: center;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 12px;
  margin-bottom: 20px;
}
.sheet-title {
  font-size: 1.45rem;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: 0.05em;
  color: #0f172a;
}
.sheet-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: #475569;
  font-weight: 600;
  margin-top: 6px;
}
.sheet-section {
  margin-bottom: 22px;
}
.sheet-section-title {
  font-size: 1.05rem;
  font-weight: 750;
  color: #0f172a;
  border-left: 4px solid var(--brand);
  padding-left: 8px;
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sheet-section-tip {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 500;
}
.sheet-chain-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 16px;
}
.sheet-q-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 14px;
  page-break-inside: avoid;
  background: #fff;
}
.sheet-q-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 8px;
  font-weight: 600;
}
.sheet-q-stem {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.6;
  color: #0f172a;
  margin-bottom: 12px;
}
.sheet-q-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  font-size: 0.94rem;
}
.sheet-parent-guide {
  background: #fefce8;
  border: 1px solid #fef08a;
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 24px;
  page-break-inside: avoid;
}
.sheet-parent-title {
  font-size: 0.98rem;
  font-weight: 750;
  color: #854d0e;
  margin: 0 0 8px;
}
.sheet-parent-item {
  font-size: 0.88rem;
  color: #713f12;
  margin-bottom: 6px;
  line-height: 1.5;
}

@media print {
  body * { visibility: hidden !important; }
  #print-modal, #print-modal *, .print-modal-dialog, .print-sheet-content, .print-sheet-content * {
    visibility: visible !important;
  }
  #print-modal {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    display: block !important;
  }
  .print-modal-backdrop, .no-print, .print-modal-header {
    display: none !important;
  }
  .print-modal-dialog {
    position: static !important;
    max-width: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .print-sheet-content {
    padding: 0 !important;
    overflow: visible !important;
  }
  .sheet-q-card, .sheet-parent-guide {
    page-break-inside: avoid !important;
  }
}
