.network-graph {
  --pre-navy: #0f172a;
  --pre-blue: #2563eb;
  --pre-border: #dbe3ee;
  --pre-muted: #64748b;
  width: 100%;
  max-width: 1280px;
  min-height: 420px;
  margin: 1.5rem auto;
  overflow: hidden;
  color: #172033;
  background: #f8fafc;
  border: 1px solid var(--pre-border);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "Microsoft YaHei", "PingFang TC", "PingFang SC", "Noto Sans CJK TC", "Noto Sans CJK SC", "Noto Sans TC", "Noto Sans SC", sans-serif;
  line-height: 1.5;
}
.network-graph *, .network-graph *::before, .network-graph *::after { box-sizing: border-box; }
.pre-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px; color: #fff; background: linear-gradient(125deg, #0f172a, #172554 60%, #0f172a); }
.pre-kicker, .pre-details-kicker { color: #93c5fd; font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.pre-title { margin: 2px 0 4px !important; color: #fff !important; font-size: clamp(22px, 2.4vw, 32px) !important; line-height: 1.15 !important; }
.pre-subtitle { max-width: 760px; margin: 0; color: #cbd5e1; font-size: 14px; }
.pre-header-stats { display: flex; gap: 8px; margin-left: auto; }
.pre-header-stat { min-width: 94px; padding: 7px 10px; border: 1px solid rgba(191,219,254,.28); border-radius: 10px; background: rgba(255,255,255,.08); text-align: center; }
.pre-header-stat strong, .pre-header-stat span { display: block; }
.pre-header-stat strong { color: #fff; font-size: 20px; line-height: 1.05; }
.pre-header-stat span { margin-top: 2px; color: #bfdbfe; font-size: 10px; white-space: nowrap; }
.pre-controls { display: flex; align-items: end; gap: 10px; flex: 0 0 auto; }
.pre-year-label { display: grid; gap: 4px; color: #dbeafe; font-size: 12px; font-weight: 700; }
.pre-year-select, .pre-button { min-height: 40px; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; color: #0f172a; font: inherit; font-size: 14px; }
.pre-year-select { min-width: 130px; padding: 8px 34px 8px 11px; }
.pre-button { padding: 8px 13px; cursor: pointer; font-weight: 700; }
.pre-button:hover, .pre-button:focus-visible, .pre-year-select:focus-visible { outline: 3px solid rgba(147,197,253,.65); outline-offset: 2px; }
.pre-content { display: flex; min-height: 0; height: calc(var(--pre-height) - 76px); }
.pre-stage { position: relative; flex: 1 1 auto; width: 100%; min-width: 0; min-height: 0; height: 100%; overflow: hidden; background: radial-gradient(circle at center, #fff 0%, #f1f5f9 78%); }
.pre-svg { display: block; width: 100%; height: 100%; min-height: 0; touch-action: none; user-select: none; }
.pre-svg text { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "Microsoft YaHei", "PingFang TC", "PingFang SC", "Noto Sans CJK TC", "Noto Sans CJK SC", "Noto Sans TC", "Noto Sans SC", sans-serif; }
.pre-direction-arrow { fill: #475569; stroke: rgba(255,255,255,.94); stroke-width: 2.5; paint-order: stroke fill; pointer-events: none; }
.pre-line { stroke: #94a3b8; stroke-width: 2.2; opacity: .72; pointer-events: stroke; transition: opacity .15s, stroke .15s, stroke-width .15s; }
.pre-line.is-highlighted { stroke: var(--pre-blue); stroke-width: 4; opacity: .95; }
.pre-line.is-dimmed, .pre-node.is-dimmed { opacity: .15; }
.pre-node { cursor: grab; transition: opacity .15s; outline: none; }
.pre-node[data-has-url="true"] { cursor: pointer; }
.pre-node[data-has-url="true"].is-dragging, .pre-node.is-dragging { cursor: grabbing; }
.pre-node.is-dragging { cursor: grabbing; }
.pre-bubble { stroke: #fff; stroke-width: 3; transition: stroke .15s, stroke-width .15s; }
.pre-node:hover .pre-bubble, .pre-node:focus-visible .pre-bubble, .pre-node.is-selected .pre-bubble { stroke: #0f172a; stroke-width: 5; }
.pre-node-name { fill: #fff; pointer-events: none; }
.pre-node-name { fill: #fff; font-size: 15px; font-weight: 800; paint-order: stroke fill; stroke: rgba(15,23,42,.72); stroke-width: 3px; stroke-linejoin: round; overflow: visible; }
.pre-empty { fill: #64748b; font-size: 18px; }
.pre-busy-overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; gap: 12px; color: #1e3a8a; background: rgba(248,250,252,.82); font-size: 14px; font-weight: 700; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s; }
.pre-busy-overlay.is-visible { opacity: 1; visibility: visible; pointer-events: auto; }
.pre-spinner { width: 28px; height: 28px; border: 3px solid #bfdbfe; border-top-color: #2563eb; border-radius: 50%; animation: pre-spin .8s linear infinite; }
@keyframes pre-spin { to { transform: rotate(360deg); } }
.pre-year-select:disabled { cursor: wait; opacity: .68; }
.pre-pan-surface { cursor: grab; }
.pre-svg.is-panning, .pre-svg.is-panning .pre-pan-surface { cursor: grabbing; }
.pre-zoom-controls { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; padding: 6px; border: 1px solid rgba(203,213,225,.9); border-radius: 10px; background: rgba(255,255,255,.94); box-shadow: 0 4px 16px rgba(15,23,42,.12); }
.pre-zoom-button { min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid #cbd5e1; border-radius: 8px; color: #0f172a; background: #fff; font: 700 18px/1 system-ui, sans-serif; cursor: pointer; }
.pre-fit-button { font-size: 12px; }
.pre-zoom-button:hover, .pre-zoom-button:focus-visible { border-color: #2563eb; outline: 2px solid rgba(37,99,235,.28); outline-offset: 1px; }
.pre-instruction { position: absolute; left: 14px; bottom: 14px; padding: 7px 10px; border: 1px solid rgba(203,213,225,.8); border-radius: 8px; color: #475569; background: rgba(255,255,255,.9); box-shadow: 0 3px 12px rgba(15,23,42,.08); font-size: 12px; pointer-events: none; }
.pre-sidebar { padding: 15px; border-left: 1px solid var(--pre-border); background: #f8fafc; }
.pre-stats { display: grid; gap: 10px; }
.pre-stat, .pre-details { padding: 15px; border: 1px solid var(--pre-border); border-radius: 12px; background: #fff; box-shadow: 0 4px 14px rgba(15,23,42,.05); }
.pre-stat strong, .pre-stat span { display: block; }
.pre-stat strong { color: var(--pre-navy); font-size: 30px; line-height: 1; }
.pre-stat span { margin-top: 5px; color: var(--pre-muted); font-size: 13px; }
.pre-details { margin-top: 12px; }
.pre-details h3 { margin: 4px 0 8px !important; color: var(--pre-navy) !important; font-size: 20px !important; }
.pre-details-kicker { color: var(--pre-blue); }
.pre-muted { margin: 0; color: var(--pre-muted); font-size: 13px; }
.pre-detail-list { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin: 10px 0 0; font-size: 13px; }
.pre-detail-list dt { color: var(--pre-muted); }
.pre-detail-list dd { margin: 0; color: var(--pre-navy); font-weight: 700; text-align: right; }
.pre-side-panel { position: relative; flex: 0 0 320px; width: 320px; min-width: 0; height: 100%; border-left: 1px solid var(--pre-border); background: #fff; transition: flex-basis .2s ease, width .2s ease; }
.pre-side-panel.is-collapsed { flex-basis: 36px; width: 36px; }
.pre-panel-close { position: absolute; z-index: 7; top: 8px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 8px; color: #475569; background: transparent; font: 500 26px/1 system-ui,sans-serif; cursor: pointer; }
/* .pre-panel-close:hover, .pre-panel-close:focus-visible { color: #0f172a; background: #f1f5f9; outline: 2px solid rgba(37,99,235,.25); } */
.pre-panel-open { display: none; width: 36px; height: 44px; border: 0; color: #334155; background: transparent; font: 700 20px/1 system-ui,sans-serif; cursor: pointer; }
.pre-side-panel.is-collapsed .pre-panel-open { display: grid; place-items: center; }
.pre-side-panel.is-collapsed .pre-panel-close { display: none; }
.pre-person-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pre-border); background: #f8fafc; }
.pre-person-summary-card { padding: 10px; border: 1px solid #dbe3ee; border-radius: 9px; background: #fff; }
.pre-person-summary-card strong, .pre-person-summary-card span { display: block; }
.pre-person-summary-card strong { color: #0f172a; font-size: 22px; line-height: 1; }
.pre-person-summary-card span { margin-top: 5px; color: #64748b; font-size: 11px; }
.pre-node.is-panel-dimmed { opacity: .22; }
.pre-node.is-selected { opacity: 1; }
.pre-node.is-selected .pre-bubble { stroke: var(--pre-highlight-bubble, #0f172a); stroke-width: 6; }
.pre-line.is-panel-dimmed, .pre-direction-arrow.is-panel-dimmed { opacity: .10; }
.pre-line.is-panel-highlighted { stroke: var(--pre-highlight-line, #2563eb); stroke-width: 3.5; opacity: .95; }
.pre-direction-arrow.is-panel-highlighted { fill: var(--pre-highlight-arrow, #2563eb); opacity: 1; }
.pre-panel-body { height: 100%; overflow: auto; }
.pre-side-panel.is-collapsed .pre-panel-close { position: absolute; z-index: 7; top: 8px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 8px; color: #475569; background: transparent; font: 500 26px/1 system-ui,sans-serif; cursor: pointer; }
/* .pre-panel-close:hover, .pre-panel-close:focus-visible { color: #0f172a; background: #f1f5f9; outline: 2px solid rgba(37,99,235,.25); } */
.pre-panel-open { display: none; width: 36px; height: 44px; border: 0; color: #334155; background: transparent; font: 700 20px/1 system-ui,sans-serif; cursor: pointer; }
.pre-side-panel.is-collapsed .pre-panel-open { display: grid; place-items: center; }
.pre-side-panel.is-collapsed .pre-panel-close { display: none; }
.pre-person-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pre-border); background: #f8fafc; }
.pre-person-summary-card { padding: 10px; border: 1px solid #dbe3ee; border-radius: 9px; background: #fff; }
.pre-person-summary-card strong, .pre-person-summary-card span { display: block; }
.pre-person-summary-card strong { color: #0f172a; font-size: 22px; line-height: 1; }
.pre-person-summary-card span { margin-top: 5px; color: #64748b; font-size: 11px; }
.pre-node.is-panel-dimmed { opacity: .22; }
.pre-node.is-selected { opacity: 1; }
.pre-node.is-selected .pre-bubble { stroke: var(--pre-highlight-bubble, #0f172a); stroke-width: 6; }
.pre-line.is-panel-dimmed, .pre-direction-arrow.is-panel-dimmed { opacity: .10; }
.pre-line.is-panel-highlighted { stroke: var(--pre-highlight-line, #2563eb); stroke-width: 3.5; opacity: .95; }
.pre-direction-arrow.is-panel-highlighted { fill: var(--pre-highlight-arrow, #2563eb); opacity: 1; }
.pre-panel-body { display: none; }
.pre-panel-heading { position: sticky; top: 0; z-index: 3; padding: 16px 12px 0 14px; border-bottom: 1px solid var(--pre-border); background: rgba(255,255,255,.97); }
.pre-panel-heading h3 { margin: 0 0 12px !important; color: #0f172a !important; font-size: 18px !important; }
.pre-panel-columns, .pre-person-row { display: grid; grid-template-columns: minmax(0,1fr) 64px; align-items: center; gap: 10px; }
.pre-relation-summary { display: grid; grid-template-columns: minmax(0,1fr) 94px; align-items: center; gap: 10px; }
.pre-panel-columns { padding: 8px 10px; color: #64748b; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.pre-panel-columns span:last-child { text-align: right; }
.pre-people-list { padding: 6px 10px 18px; }
.pre-person-row { width: 100%; padding: 11px 10px; border: 0; border-bottom: 1px solid #eef2f7; color: #1e293b; background: transparent; font: inherit; text-align: left; cursor: pointer; }
.pre-person-row:hover, .pre-person-row:focus-visible { border-radius: 8px; outline: 2px solid rgba(37,99,235,.25); background: #eff6ff; }
.pre-person-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre-person-row-count { text-align: right; }
.pre-panel-back { margin: 0 0 10px; padding: 5px 0; border: 0; color: #2563eb; background: transparent; font: 700 13px/1.3 system-ui,sans-serif; cursor: pointer; }
.pre-person-relations { padding: 12px; }
.pre-year-section { margin-bottom: 12px; padding: 10px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; }
.pre-year-section.is-current-year { border-color: #60a5fa; background: #eff6ff; box-shadow: 0 0 0 2px rgba(96,165,250,.12); }
.pre-year-section h4 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px !important; color: #0f172a !important; font-size: 14px !important; }
.pre-current-badge { padding: 3px 7px; border-radius: 999px; color: #1d4ed8; background: #dbeafe; font-size: 10px; text-transform: uppercase; }
.pre-relation-summary { padding: 7px 0; border-top: 1px solid rgba(203,213,225,.65); font-size: 13px; }
.pre-relation-summary strong { text-align: right; }
.pre-message { margin: 0; padding: 28px; border-radius: 14px; }
.pre-message strong { display: block; margin-bottom: 6px; }
.pre-loading { color: #1e40af; background: #eff6ff; }
.pre-error { color: #991b1b; background: #fef2f2; }
@media (max-width: 750px) {
  .pre-content { flex-direction: column; overflow: auto; }
  .pre-stage { flex: 0 0 62vh; min-height: 430px; }
  .pre-side-panel, .pre-side-panel.is-collapsed { flex: 0 0 auto; width: 100%; height: auto; max-height: 45vh; border-top: 1px solid var(--pre-border); border-left: 0; }
  .pre-side-panel.is-collapsed { max-height: 44px; }
    .pre-panel-close { position: absolute; z-index: 7; top: 8px; right: 8px; width: 34px; height: 34px; border: 0; border-radius: 8px; color: #475569; background: transparent; font: 500 26px/1 system-ui,sans-serif; cursor: pointer; }
/* .pre-panel-close:hover, .pre-panel-close:focus-visible { color: #0f172a; background: #f1f5f9; outline: 2px solid rgba(37,99,235,.25); } */
.pre-panel-open { display: none; width: 36px; height: 44px; border: 0; color: #334155; background: transparent; font: 700 20px/1 system-ui,sans-serif; cursor: pointer; }
.pre-side-panel.is-collapsed .pre-panel-open { display: grid; place-items: center; }
.pre-side-panel.is-collapsed .pre-panel-close { display: none; }
.pre-person-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pre-border); background: #f8fafc; }
.pre-person-summary-card { padding: 10px; border: 1px solid #dbe3ee; border-radius: 9px; background: #fff; }
.pre-person-summary-card strong, .pre-person-summary-card span { display: block; }
.pre-person-summary-card strong { color: #0f172a; font-size: 22px; line-height: 1; }
.pre-person-summary-card span { margin-top: 5px; color: #64748b; font-size: 11px; }
.pre-node.is-panel-dimmed { opacity: .22; }
.pre-node.is-selected { opacity: 1; }
.pre-node.is-selected .pre-bubble { stroke: var(--pre-highlight-bubble, #0f172a); stroke-width: 6; }
.pre-line.is-panel-dimmed, .pre-direction-arrow.is-panel-dimmed { opacity: .10; }
.pre-line.is-panel-highlighted { stroke: var(--pre-highlight-line, #2563eb); stroke-width: 3.5; opacity: .95; }
.pre-direction-arrow.is-panel-highlighted { fill: var(--pre-highlight-arrow, #2563eb); opacity: 1; }
.pre-panel-body { max-height: 45vh; }

  .pre-header { align-items: flex-start; flex-direction: column; }
  .pre-header-stats { display: flex; gap: 8px; margin-left: auto; }
.pre-header-stat { min-width: 94px; padding: 7px 10px; border: 1px solid rgba(191,219,254,.28); border-radius: 10px; background: rgba(255,255,255,.08); text-align: center; }
.pre-header-stat strong, .pre-header-stat span { display: block; }
.pre-header-stat strong { color: #fff; font-size: 20px; line-height: 1.05; }
.pre-header-stat span { margin-top: 2px; color: #bfdbfe; font-size: 10px; white-space: nowrap; }
.pre-controls { width: 100%; flex-wrap: wrap; }
  .pre-header-stats { width: 100%; margin-left: 0; }
  .pre-header-stat { flex: 1; }
}
@media (max-width: 520px) {
  .pre-header { padding: 18px; }
  .pre-controls, .pre-year-label, .pre-year-select, .pre-button { width: 100%; }
  .pre-instruction { right: 14px; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .network-graph * { scroll-behavior: auto !important; transition: none !important; }
}

/* v2.8 panel visibility corrections */
.pre-side-panel:not(.is-collapsed) .pre-panel-body { display: block !important; }
.pre-side-panel:not(.is-collapsed) .pre-panel-open { display: none !important; }
.pre-side-panel:not(.is-collapsed) .pre-panel-close { display: block !important; }
.pre-side-panel.is-collapsed .pre-panel-body { display: none !important; }
.pre-side-panel.is-collapsed .pre-panel-open { display: grid !important; place-items: center; }
.pre-side-panel.is-collapsed .pre-panel-close { display: none !important; }

@media (max-width: 750px) {
  .pre-side-panel,
  .pre-side-panel.is-collapsed,
  .pre-side-panel.is-mobile-panel {
    flex: 0 0 auto !important;
    width: 100% !important;
    height: auto !important;
    max-height: 45vh !important;
    border-top: 1px solid var(--pre-border) !important;
    border-left: 0 !important;
  }
  .pre-side-panel .pre-panel-body,
  .pre-side-panel.is-collapsed .pre-panel-body,
  .pre-side-panel.is-mobile-panel .pre-panel-body {
    display: block !important;
    max-height: 45vh;
    overflow: auto;
  }
  .pre-side-panel .pre-panel-open,
  .pre-side-panel .pre-panel-close,
  .pre-side-panel.is-collapsed .pre-panel-open,
  .pre-side-panel.is-collapsed .pre-panel-close {
    display: none !important;
  }
}

/* v2.9 mobile controls: panel is permanently expanded below the diagram. */
@media (max-width: 750px) {
  .pre-side-panel .pre-panel-open,
  .pre-side-panel .pre-panel-close,
  .pre-side-panel:not(.is-collapsed) .pre-panel-close,
  .pre-side-panel.is-collapsed .pre-panel-open,
  .pre-side-panel.is-mobile-panel .pre-panel-open,
  .pre-side-panel.is-mobile-panel .pre-panel-close,
  .pre-side-panel button[aria-label="Open information panel"],
  .pre-side-panel button[aria-label="Collapse information panel"] {
    display: none !important;
    visibility: hidden !important;
  }
}

.pre-person-profile-link { display: inline-flex; align-items: center; margin: -4px 0 12px; color: #2563eb; font-size: 13px; font-weight: 700; text-decoration: none; }
/* .pre-person-profile-link:hover, .pre-person-profile-link:focus-visible { text-decoration: underline; outline: 2px solid rgba(37,99,235,.22); outline-offset: 2px; } */
.pre-year-section.is-current-year { scroll-margin-top: 90px; }

/* v3.1 person heading actions */
.pre-person-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.pre-person-title-row h3 { min-width: 0; margin: 0 !important; overflow-wrap: anywhere; }
.pre-person-title-row .pre-person-profile-link { 
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; margin: 0; padding: 8px 12px; border-radius: 8px; color: #fff; 
  background: #2563eb; font-size: 12px; font-weight: 800; line-height: 1; text-decoration: none; white-space: nowrap; 
  /* box-shadow: 0 2px 6px rgba(37,99,235,.24);  */
  color: #1d4ed8; background: #dbeafe; font-size: 10px; text-transform: uppercase
}
/* .pre-person-title-row .pre-person-profile-link:hover,
.pre-person-title-row .pre-person-profile-link:focus-visible { color: #fff; background: #1d4ed8; text-decoration: none; outline: 3px solid rgba(37,99,235,.25); outline-offset: 2px; } */


/* v3.2 stable viewport and responsive header layout */
.network-graph {
  display: flex;
  flex-direction: column;
  height: var(--pre-height);
  min-height: 0;
  margin-top: 0;
  margin-bottom: 0;
}
.pre-header { flex: 0 0 auto; }
.pre-content {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
}
.pre-stage,
.pre-side-panel { min-height: 0; height: 100%; }

/* Tablet: title first; counts and year control share the second row. */
@media (min-width: 751px) and (max-width: 1100px) {
  .pre-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "heading heading"
      "stats controls";
    align-items: center;
    row-gap: 10px;
  }
  .pre-header > div:first-child { grid-area: heading; }
  .pre-header-stats {
    grid-area: stats;
    justify-self: start;
    margin-left: 0;
  }
  .pre-controls {
    grid-area: controls;
    justify-self: end;
    width: auto;
  }
  .pre-year-label { display: flex; align-items: center; gap: 8px; }
}

/* Mobile: stable canvas and panel heights from first paint. The panel is
   permanently visible below the graph and never grows after page scrolling. */
@media (max-width: 750px) {
  .network-graph {
    height: auto !important;
    min-height: 0;
    overflow: visible;
  }
  .pre-header { flex: none; }
  .pre-content {
    display: flex;
    flex-direction: column;
    flex: none;
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .pre-stage {
    flex: none;
    width: 100%;
    height: 58svh;
    min-height: 430px;
    max-height: 620px;
  }
  .pre-side-panel,
  .pre-side-panel.is-collapsed,
  .pre-side-panel.is-mobile-panel {
    flex: none !important;
    width: 100% !important;
    height: 46svh !important;
    min-height: 360px !important;
    max-height: 520px !important;
    overflow: hidden;
  }
  .pre-side-panel .pre-panel-body,
  .pre-side-panel.is-collapsed .pre-panel-body,
  .pre-side-panel.is-mobile-panel .pre-panel-body {
    display: block !important;
    width: 100%;
    height: 100% !important;
    max-height: none !important;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}


/* v3.3 viewport margin, overflow, and iPad-size header fixes */
.network-graph {
  width: calc(100% - 24px);
  max-width: 1280px;
  margin: 12px auto;
  height: var(--pre-height);
  overflow: hidden;
}
.pre-header,
.pre-content,
.pre-stage,
.pre-side-panel { max-width: 100%; }
.pre-content { width: 100%; overflow: hidden; }
.pre-stage { flex: 1 1 0; width: auto; overflow: hidden; }
.pre-side-panel { flex-shrink: 0; }
.pre-svg { max-width: 100%; }

/* Tablet and small laptop: title above; counts and year filter share one row.
   1366px includes iPad mini landscape and common tablet browser widths. */
@media (min-width: 751px) and (max-width: 1366px) {
  .pre-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "heading heading"
      "stats controls";
    align-items: center;
    column-gap: 16px;
    row-gap: 10px;
  }
  .pre-header > div:first-child { grid-area: heading; min-width: 0; }
  .pre-header-stats {
    grid-area: stats;
    justify-self: start;
    width: auto;
    margin-left: 0;
  }
  .pre-controls {
    grid-area: controls;
    justify-self: end;
    width: auto;
    flex-wrap: nowrap;
  }
  .pre-year-label { display: flex; align-items: center; gap: 8px; }
}

@media (max-width: 750px) {
  .network-graph {
    width: calc(100% - 20px);
    margin: 10px auto;
    overflow-x: hidden;
  }
  .pre-header,
  .pre-content,
  .pre-stage,
  .pre-side-panel { width: 100%; max-width: 100%; }
}


/* v3.4 exact viewport fit and unified relationship highlighting */
.network-graph {
  min-height: 0 !important;
  max-height: calc(100dvh - 48px);
  margin: 12px auto;
}
.pre-content,
.pre-stage,
.pre-side-panel,
.pre-svg { min-height: 0 !important; }

/* Keep line and arrow colours in one visual system. Arrowheads previously
   appeared as a third, more-solid colour because their dark fill and white
   outline remained visually stronger than dimmed line strokes. */
.pre-line {
  stroke: #94a3b8;
  stroke-width: 2.2;
  opacity: .72;
}
.pre-direction-arrow {
  fill: #94a3b8;
  stroke: rgba(255,255,255,.65);
  stroke-width: 1.5;
  opacity: .72;
}
.pre-line.is-panel-highlighted {
  stroke: var(--pre-highlight-line, #2563eb) !important;
  stroke-width: 3.5;
  opacity: .95 !important;
}
.pre-direction-arrow.is-panel-highlighted {
  fill: var(--pre-highlight-arrow, #2563eb) !important;
  stroke: rgba(255,255,255,.9);
  opacity: .95 !important;
}
.pre-line.is-panel-dimmed {
  stroke: #94a3b8 !important;
  opacity: .08 !important;
}
.pre-direction-arrow.is-panel-dimmed {
  fill: #94a3b8 !important;
  stroke: transparent !important;
  opacity: .08 !important;
}

/* Tablet header starts immediately above the new 750px mobile breakpoint. */
@media (min-width: 751px) and (max-width: 1366px) {
  .pre-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "heading heading"
      "stats controls";
  }
  .pre-header > div:first-child { grid-area: heading; }
  .pre-header-stats { grid-area: stats; width: auto; margin-left: 0; }
  .pre-controls { grid-area: controls; width: auto; justify-self: end; }
}

@media (max-width: 750px) {
  .network-graph { max-height: none; }
}


/* v3.5 authoritative header layout reset */
@media (min-width: 1101px) {
  .pre-header { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 20px; }
  .pre-header > div:first-child { flex: 1 1 auto; min-width: 0; }
  .pre-header-stats { display: flex; flex: 0 0 auto; width: auto; margin-left: auto; }
  .pre-controls { display: flex; flex: 0 0 auto; width: auto; }
  .pre-year-label { display: grid; width: auto; }
  .pre-year-select { width: auto; min-width: 150px; }
}
@media (min-width: 751px) and (max-width: 1100px) {
  .pre-header { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px 16px; }
  .pre-header > div:first-child { flex: 1 1 420px; min-width: 0; }
  .pre-header-stats { flex: 0 0 auto; width: auto; margin-left: auto; }
  .pre-controls { display: flex; flex: 1 0 100%; width: 100%; margin: 0; }
  .pre-year-label, .pre-year-select { width: 100%; max-width: none; }
}
@media (max-width: 750px) {
  .pre-header { display: flex; flex-direction: column; align-items: stretch; }
  .pre-header > div:first-child, .pre-header-stats, .pre-controls, .pre-year-label, .pre-year-select { width: 100%; max-width: none; }
  .pre-header-stats { margin-left: 0; }
}

/* Fix mobile graph area disappearing */
@media (max-width: 750px) {
  .network-graph {
    display: flex;
    flex-direction: column;
    width: calc(100% - 20px);
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible;
    border-radius: 18px;
  }
   .pre-content {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible;
  }

  .pre-stage {
    position: relative;
    display: block;
    flex: 0 0 58svh !important;
    width: 100% !important;
    height: 58svh !important;
    min-height: 430px !important;
    max-height: 620px !important;
    overflow: hidden;
  }

  .pre-svg {
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
  }
  .pre-side-panel,
  .pre-side-panel.is-collapsed,
  .pre-side-panel.is-mobile-panel {
    flex: 0 0 46s*h !important;
    width: 100% !important;
    height: 46svh !important;
    min-height: 360px !important;
    max-height: 520px !important;  }
}

/* Preserve rounded explorer corners on mobile */
@media (max-width: 750px) {
  .pre-explorer {
    border: 1px solid var(--pre-border);
    border-radius: 18px;
    overflow: hidden !important;
  }

  /* Top corners belong to the header */
  .pre-header {
    border-radius: 17px 17px 0 0;
  }

  /* Bottom corners belong to the panel */
  .pre-side-panel,
  .pre-side-panel.is-collapsed,
  .pre-side-panel.is-mobile-panel {
    border-radius: 0 0 17px 17px;
    overflow: hidden;
  }
}

/* Current-year badge and external VIEW button; related function: personYearUrl */
.pre-year-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.pre-current-year-view {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid #2563eb;
  border-radius: 8px;
  color: #fff;
  background: #2563eb;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
}

.pre-current-year-view:hover {
  border-color: #1d4ed8;
  color: #fff;
  background: #1d4ed8;
  text-decoration: none;
}

.pre-current-year-view:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.3);
  outline-offset: 2px;
}

/* Optional: Label the current-year block */
.pre-current-badge {
  display: none;
}

/* Optional: Show the profile link towards repo searching result*/
/* .pre-person-title-row .pre-person-profile-link {
  display: none;
} */

/* Prevent long year labels from pushing the buttons outside the panel */
.pre-year-section h4 {
  align-items: center;
  gap: 6px;
}

.pre-year-section h4 > :first-child {
  min-width: 0;
}