/* One connected network. Semantic zoom preserves the same world positions. */
.post-page .page-shell:has(#market-graph) { max-width: none; }
.article-shell.article-shell-wide > #market-graph { max-width: 100%; }
.article-shell:has(#market-graph) .post-header { margin-bottom: 0; }
.article-shell:has(#market-graph) .post-meta { display: none; }
#market-graph { min-width: 0; font: 400 var(--text-control)/1.5 var(--font); }
#market-graph [hidden] { display: none !important; }
#market-graph :is(h2,h3,p,ul) { margin: 0; }
#market-graph button { font: inherit; cursor: pointer; }
#market-graph button:disabled { cursor: default; opacity: var(--disabled-opacity); }
#market-graph a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.mg-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); flex-wrap: wrap; padding: 0 0 var(--space-2); }
.mg-legend, .mg-tools { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.mg-legend { color: var(--muted); font-size: var(--text-caption); }
.mg-legend span { display: inline-flex; align-items: center; gap: 5px; }
.mg-legend i { width: 20px; height: 0; border-top: 2px solid var(--muted); }
.mg-legend .mg-dashed { border-color: var(--gold); border-top-style: dashed; }
.mg-legend .mg-member { border-color: var(--hairline); border-top-width: 1px; }
.mg-tools { margin-left: auto; gap: var(--space-2); }
.mg-tools time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: var(--text-caption); margin-right: var(--space-2); }
.mg-tools button, #mg-close {
  min-height: var(--control-height); min-width: var(--control-height);
  padding: 0 var(--space-2); color: var(--ink); background: var(--card);
  border: 1px solid var(--hairline); border-radius: var(--radius-sm);
}
.mg-tools button:hover:not(:disabled), #mg-close:hover { background: var(--surface-hover); }
#mg-zoom-in, #mg-zoom-out, #mg-close { font-size: 1.3rem; }
.mg-viewport {
  position: relative; width: 100%; height: max(400px, calc(100dvh - 162px));
  overflow: clip; background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--radius-card); touch-action: none; overscroll-behavior: contain; cursor: grab;
}
.mg-viewport.is-dragging, .mg-viewport.is-dragging * { cursor: grabbing !important; }
#mg-svg { display: block; width: 100%; height: 100%; user-select: none; touch-action: none; outline-offset: -3px; }
.mg-scene text { font-family: var(--font); pointer-events: none; }
.mg-lane { fill: var(--paper); fill-opacity: .66; stroke: var(--row-divider); stroke-width: 1; }
.mg-tier { fill: var(--muted); font-weight: 600; letter-spacing: .06em; }
.mg-node { cursor: pointer; outline: none; }
.mg-node-box { fill: var(--card); stroke: var(--field-border); stroke-width: 1; }
.mg-node[data-type="sector"] .mg-node-box { stroke-width: 1.5; }
.mg-node[data-direction="up"] .mg-node-box { fill: var(--positive-soft); stroke: var(--up); stroke-opacity: .66; }
.mg-node[data-direction="down"] .mg-node-box { fill: var(--negative-soft); stroke: var(--down); stroke-opacity: .66; }
.mg-node:hover .mg-node-box, .mg-node:focus-visible .mg-node-box, .mg-node[aria-pressed="true"] .mg-node-box { stroke: var(--accent); stroke-width: 2.5; stroke-opacity: 1; }
.mg-node-label { fill: var(--ink); font-size: 14px; font-weight: 500; }
.mg-node-subtitle { fill: var(--muted); font-size: 12px; }
.mg-node-change { fill: var(--muted); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mg-node-change[data-direction="up"], #mg-detail-change[data-direction="up"] { fill: var(--up); color: var(--up); }
.mg-node-change[data-direction="down"], #mg-detail-change[data-direction="down"] { fill: var(--down); color: var(--down); }
.mg-overview-text { fill: var(--ink); font-weight: 600; }
.mg-overview-return { font-weight: 600; font-variant-numeric: tabular-nums; fill: var(--muted); }
.mg-overview-return[data-direction="up"] { fill: var(--up); }
.mg-overview-return[data-direction="down"] { fill: var(--down); }
.mg-edge { fill: none; stroke: var(--muted); stroke-width: 1.4; opacity: .29; pointer-events: none; }
.mg-edge-membership { stroke: var(--faint); stroke-width: 1; opacity: .24; }
.mg-edge-counterexample { stroke: var(--gold); stroke-dasharray: 6 5; opacity: .8; }
/* Keep the dashed stroke unchanged; use a continuous screen-space hit target. */
.mg-counter-hit { fill: none; stroke: transparent; stroke-width: 12px; vector-effect: non-scaling-stroke; pointer-events: stroke; }
.mg-edge-counterexample.is-counter-hovered { opacity: 1; }
.mg-counter-label {
  position: absolute; z-index: 2; pointer-events: none;
  padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm);
  border: 1px solid var(--gold); color: var(--gold); background: var(--card);
  font: 600 var(--text-caption)/1.3 var(--font); white-space: nowrap;
  box-shadow: var(--shadow);
}
.mg-summary-edge { opacity: .4; stroke-width: 1; vector-effect: non-scaling-stroke; }
.mg-summary-edge.mg-edge-counterexample { opacity: .72; stroke-dasharray: 4 3; }
.mg-edge.is-related { opacity: 1; stroke-width: 2.5; }
.mg-edge.is-related:not(.mg-edge-counterexample) { stroke: var(--accent); }
.mg-scene[data-detail="overview"] .mg-actual-edges, .mg-scene:not([data-detail="overview"]) .mg-summary-edges { display: none; }
.mg-scene[data-detail="overview"] .mg-node[data-type="stock"] .mg-node-box,
.mg-scene[data-detail="overview"] .mg-node[data-type="industry"] .mg-node-box { stroke-width: .7; }
.mg-scene[data-detail="overview"] .mg-lane { stroke-width: 3; }
.mg-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-5); border-bottom: 1px solid var(--hairline); }
#mg-detail {
  width: min(580px, calc(100% - 32px)); max-width: none; max-height: min(85dvh, 840px);
  padding: 0; color: var(--body-ink); background: var(--card);
  border: 1px solid var(--hairline); border-radius: var(--radius-card); box-shadow: var(--shadow-dialog);
  overflow: hidden; margin: auto;
}
#mg-detail[open] { display: flex; flex-direction: column; }
#mg-detail::backdrop { background: var(--backdrop); }
#mg-detail-kind { color: var(--muted); font-size: var(--text-caption); }
#mg-detail-title { color: var(--ink); font-size: var(--text-section); text-wrap: pretty; }
#mg-detail-change { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
#mg-detail-change:empty { display: none; }
#mg-close { flex: none; border: 0; background: var(--sunken); }
.mg-detail-body { padding: var(--space-5); overflow-y: auto; overscroll-behavior: contain; min-height: 0; font-size: var(--text-body); line-height: 1.55; display: grid; gap: var(--space-5); }
.mg-detail-body h3 { font-size: var(--text-control); color: var(--muted); font-weight: 600; padding-bottom: var(--space-1); }
.mg-detail-body section[data-field="counterexample"] h3 { color: var(--gold); }
.mg-detail-body details summary { cursor: pointer; color: var(--link); min-height: var(--control-height); align-content: center; font-size: var(--text-control); }
.mg-detail-body ul { padding-left: 0; list-style: none; }
.mg-detail-body li { padding: var(--space-2) 0; border-top: 1px solid var(--row-divider); }
.mg-detail-body li small { display: block; color: var(--muted); font-size: var(--text-caption); }
.mg-connection { text-align: start; border: 0; padding: 0; background: none; color: var(--link); min-height: var(--control-height); text-decoration: underline; }
.mg-connection-kind { color: var(--muted); font-size: var(--text-caption); }
@media (max-width: 640px) {
  .mg-toolbar { gap: var(--space-1); }
  .mg-legend { gap: var(--space-2); font-size: .72rem; }
  .mg-tools { width: 100%; justify-content: flex-end; }
  .mg-tools time { margin-right: auto; }
  .mg-viewport { height: max(360px, calc(100dvh - 196px)); }
  #mg-detail { margin: auto auto 0; width: 100%; max-height: 85dvh; border-radius: var(--radius-card) var(--radius-card) 0 0; }
  .mg-detail-header, .mg-detail-body { padding: var(--space-4); }
  .mg-detail-body { padding-bottom: max(var(--space-5), env(safe-area-inset-bottom)); }
}
