.map-main { padding-top: 26px; padding-bottom: 28px; }
.map-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:6px; }
.map-title { display:flex; flex-wrap:wrap; align-items:center; gap:5px 10px; }
.map-heading h1 { margin:0; }
.map-actions { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.map-actions button, .map-actions select { border:1px solid var(--line); border-radius:8px; background:var(--surface); color:var(--ink); padding:7px 12px; font:inherit; }
.map-actions button:hover, .map-actions select:hover { border-color:var(--blue); }
.map-actions label { color:var(--muted); font-size:14px; }
.map-actions select { margin-left:4px; }
.map-state { margin:0 0 14px; color:var(--muted); font-size:14px; }
.map-frame { position:relative; isolation:isolate; }
#network-map {
  height:clamp(450px, 75vh, 860px);
  height:clamp(450px, 75dvh, 860px);
  border:1px solid var(--line); border-radius:12px;
  background:radial-gradient(ellipse at 46% 28%, #1e3549, #101e31 85%);
}
.map-fullscreen-button { position:absolute; right:10px; bottom:30px; z-index:710; min-height:36px; padding:6px 10px; border:1px solid #496078; border-radius:7px; background:#101824f5; color:var(--ink); font-size:13px; font-weight:600; }
.map-fullscreen-button:hover, .map-fullscreen-button:focus-visible { border-color:var(--blue); }
.map-frame.map-expanded #network-map { height:100%; border:0; border-radius:0; }
.map-frame.map-viewport-expanded { position:fixed; inset:0; z-index:1000; }
body.map-viewport-expanded { overflow:hidden; }
body.map-viewport-expanded > .site-header,
body.map-viewport-expanded .map-main > :not(.map-frame) { visibility:hidden; }
.map-state-label, .map-town-label, .map-river-label { text-align:center; white-space:nowrap; text-shadow:0 1px 3px #0a1322; }
.map-state-label { color:#9db7cc; font:700 11px/16px var(--font); letter-spacing:0.14em; text-transform:uppercase; }
.map-town-label { color:#c4d7e5; font:600 11px/16px var(--font); }
.map-river-label { color:#8fbed2; font:italic 11px/16px var(--font); }
.map-wide-view .leaflet-map-places-pane { visibility:hidden; }
#network-map .leaflet-control-attribution { background:#121f31ed; color:var(--muted); }
#network-map .leaflet-control-attribution a { color:#b2cbe0; }
#network-map .leaflet-control-scale-line { background:#121f31df; border-color:#839db5; color:#cedeea; }
.map-heard {
  position:absolute; z-index:500; top:10px; left:10px;
  display:flex; flex-direction:column; align-items:flex-start; gap:6px;
  width:360px; max-width:calc(100% - 64px); max-height:calc(100% - 34px);
  pointer-events:none;
}
.map-heard-panel {
  width:100%; min-height:0; padding:12px 14px; overflow:auto; overscroll-behavior:contain;
  border:1px solid var(--line); border-radius:8px; background:#101824f5; pointer-events:auto;
}
.map-heard-toolbar { display:flex; flex:none; align-items:center; gap:8px; }
.map-heard-toggle {
  display:inline-flex; flex:none; align-items:center; gap:9px; min-height:44px; padding:7px 12px;
  border:1px solid #496078; border-radius:8px; background:#101824f5; color:var(--ink);
  font:inherit; font-weight:600; pointer-events:auto;
}
.map-heard-toggle:hover { border-color:var(--blue); }
.map-heard-toggle::after {
  content:""; width:6px; height:6px; border:solid currentColor; border-width:0 1.5px 1.5px 0;
  transform:translateY(-2px) rotate(45deg);
}
.map-heard-toggle[aria-expanded="true"]::after { transform:translateY(2px) rotate(225deg); }
.map-heard-size { display:none; }
.map-heard ol { list-style:none; margin:0; padding:0; font-size:15px; line-height:1.35; }
.map-heard .heard-row { padding:4px 9px; }
.map-heard li + li { margin-top:4px; border-top:1px solid #233349; }
.map-heard .map-heard-meta { flex-wrap:wrap; align-items:baseline; gap:1px 8px; }
.map-heard .peer-result { padding:0; max-width:none; color:#a9d9fc; font-size:13px; text-align:left; white-space:nowrap; font-variant-numeric:tabular-nums; }
.map-heard .heard-detail small { color:inherit; font-size:12px; }
.map-legend { display:flex; flex-wrap:wrap; gap:5px 16px; color:var(--muted); font-size:13px; margin:10px 0; }
.map-legend i, .map-dot { background:#ff4c56; border:2px solid #32151a; border-radius:50%; }
.map-dot { box-shadow:0 0 0 1px #ffe9ea; }
.map-hub-peer-label {
  position:absolute; top:50%; left:calc(100% + 5px); transform:translateY(-50%);
  padding:3px 6px; border:1px solid #496078; border-radius:5px; background:#101824f5;
  color:var(--ink); font:600 11px/1.3 var(--font); white-space:nowrap; pointer-events:none;
}
.map-node-number {
  display:none;
  position:absolute;
  left:calc(50% + var(--map-node-number-shift, 0px));
  bottom:calc(100% + 4px + var(--map-node-number-lift, 0px));
  transform:translateX(-50%);
  padding:0 2px;
  border-radius:3px;
  background:#101824ed;
  color:#f5f8fc;
  font:600 11px/13px var(--mono);
  white-space:nowrap;
  pointer-events:none;
  user-select:none;
}
.map-node-number::after {
  content:"";
  position:absolute;
  top:100%;
  left:calc(50% - 0.5px);
  width:1px;
  height:var(--map-node-number-leader-length, 0px);
  background:#c5d4e296;
  transform:rotate(var(--map-node-number-leader-angle, 0rad));
  transform-origin:top center;
}
.map-show-node-numbers .map-node-number { display:block; }
.map-node-number-obscured, .leaflet-zoom-anim .map-node-number { visibility:hidden; }
.map-legend i { display:inline-block; width:13px; height:13px; vertical-align:middle; }
.map-legend .hub, .map-dot.hub { background:#ff8a92; border-radius:2px; }
.map-legend .outside, .map-dot.outside,
.map-legend .recent, .map-dot.recent { background:transparent; border-color:#ff98a0; }
.map-legend .recent, .map-dot.recent { border-color:#db8b92; border-style:dashed; }
.map-dot.outside, .map-dot.recent { box-shadow:0 0 0 1px #32151a; }
.map-dot:hover { box-shadow:0 0 0 2px #ffe9ea, 0 0 12px #ff808a80; }
.map-legend .line { width:20px; height:2px; border:0; background:#ff6670; border-radius:0; opacity:0.58; }
.map-legend .line.snapshot { opacity:0.7; background:repeating-linear-gradient(90deg,#ff6670 0 4px,transparent 4px 7px); }
.map-dot.map-dot-active {
  background:#ffb6bd;
  border-color:#ff4c56;
  box-shadow:0 0 0 2px #ffe9ea, 0 0 0 5px #ff4c5680, 0 0 15px 5px #ff4c56;
}
.map-dot.map-dot-active:is(.outside, .recent) { background:transparent; border-color:#ffb6bd; }
.map-link-active { filter:drop-shadow(0 0 4px var(--green)); }
.map-legend .line.map-link-active { height:4px; background:var(--green); opacity:1; }
.map-dot:focus-visible { outline:2px solid #fff; outline-offset:3px; }
.leaflet-tooltip.map-node-tooltip { padding:4px 8px; border:1px solid #496078; border-radius:5px; background:#101824; color:var(--ink); font:600 13px/1.35 var(--font); }
.leaflet-tooltip-top.map-node-tooltip::before { border-top-color:#496078; }
.leaflet-popup.map-popup .leaflet-popup-content-wrapper,
.leaflet-popup.map-popup .leaflet-popup-tip { background:var(--surface); color:var(--ink); }
.leaflet-popup.map-popup .leaflet-popup-content { margin:12px; font-family:var(--font); }
.leaflet-popup.map-popup .leaflet-popup-close-button { color:var(--ink); }
.map-popup .node-card { min-width:0; }
.node-heading .map-repeater-last-heard {
  margin:5px 0 0; color:var(--muted); font-size:13px; font-variant-numeric:tabular-nums;
}
.map-popup .outside-card { padding:8px 12px 4px; }
.map-popup .outside-card p { margin:6px 0; }
#map-unlocated button { color:var(--blue); border:0; background:none; text-decoration:underline; cursor:pointer; }
#map-unlocated { margin-top:12px; }
.map-unlocated-dialog { max-width:min(520px, calc(100% - 24px)); max-height:85vh; overflow:auto; background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:10px; }
.map-unlocated-dialog button { margin-bottom:8px; }
@media (min-width:761px) {
  body[data-page="network-map"] {
    --map-gutter:clamp(18px, 2.25vw, 36px);
    display:flex; flex-direction:column;
    min-height:100vh;
    min-height:100dvh;
  }
  body[data-page="network-map"] > .site-header {
    flex:none; width:100%; max-width:1920px; padding:12px var(--map-gutter);
  }
  .map-main {
    display:flex; flex:1 0 auto; flex-direction:column;
    width:100%; max-width:1920px; padding:14px var(--map-gutter) 12px;
  }
  .map-heading { margin-bottom:4px; }
  .map-heading h1 { font-size:34px; }
  .map-state { margin-bottom:9px; }
  .map-frame {
    flex:1 0 auto;
    min-height:clamp(510px, 76vh, 850px);
    min-height:clamp(510px, 76dvh, 850px);
  }
  .map-frame.map-expanded { min-height:0; }
  #network-map { position:absolute; inset:0; height:auto; }
  .map-legend { margin:8px 0 0; }
  .map-heard-toggle[aria-expanded="true"] + .map-heard-size {
    display:inline-flex; gap:2px; padding:2px; pointer-events:auto;
    border:1px solid #496078; border-radius:8px; background:#101824f5;
  }
  .map-heard-size button {
    min-height:36px; padding:4px 9px; border:0; border-radius:5px;
    background:none; color:var(--muted); font:600 13px/1.3 var(--font);
  }
  .map-heard-size button:hover { background:var(--surface-hover); color:var(--ink); }
  .map-heard-size button[aria-pressed="true"] { background:#24334a; color:var(--ink); }
  .map-heard-size button:focus-visible { outline-offset:0; }
  .map-heard[data-size="large"] { width:min(480px, 55%); }
  .map-heard[data-size="large"] ol { font-size:18px; }
  .map-heard[data-size="large"] .peer-result { font-size:15px; }
  .map-heard[data-size="large"] .heard-detail small { font-size:13px; }
}
@media (max-width:600px) {
  .map-heading { flex-direction:column; align-items:flex-start; }
}
@media (max-width:760px), (max-height:540px) {
  .map-heard-panel { max-height:56vh; max-height:56dvh; }
}
