/* Network map (netmap.js). Picks up the host site's colours: the portfolio's --accent/--ink/--surface,
   or the docs site's --md-* variables, with plain fallbacks. */
.netmap, .nm-panel {
  --nm-accent: var(--accent, var(--md-primary-fg-color, #c2183a));
  --nm-ink: var(--ink, var(--md-default-fg-color, #17161b));
  --nm-muted: var(--muted, var(--md-default-fg-color--light, #5e5a66));
  --nm-border: var(--surface-border, var(--md-default-fg-color--lightest, rgba(127, 127, 127, .25)));
  --nm-card: #fff;              /* opaque, so lines pass behind cards instead of through them */
  --nm-shadow: 0 1px 2px rgba(20, 16, 24, .05), 0 6px 18px rgba(20, 16, 24, .06);
  --nm-radius: 14px;
}
[data-theme="mirai"] .netmap, [data-theme="mirai"] .nm-panel {
  --nm-card: #1e1636;
  --nm-shadow: 0 8px 28px rgba(5, 0, 20, .45);
}
[data-md-color-scheme="slate"] .netmap, [data-md-color-scheme="slate"] .nm-panel {
  --nm-card: #1b1418;
  --nm-shadow: 0 8px 28px rgba(0, 0, 0, .45);
}
.netmap {
  position: relative;
  color: var(--nm-ink);
  font-size: 14px;
  line-height: 1.4;
  margin: 1.5em 0;
}
.netmap *, .nm-panel * { box-sizing: border-box; }
.netmap button, .nm-panel button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- toolbar */
.nm-toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.nm-search {
  flex: 1 1 220px; max-width: 300px; padding: 9px 14px; font: inherit; color: inherit;
  background: var(--nm-card); border: 1px solid var(--nm-border); border-radius: 999px;
}
.nm-search:focus { outline: 2px solid var(--nm-accent); outline-offset: 1px; }
.nm-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.nm-key {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 0; font-size: 12px;
  color: var(--nm-muted); background: none; border: 0; cursor: pointer;
}
.nm-key:hover { color: var(--nm-ink); }
.nm-key[aria-pressed="false"] { opacity: .4; }
.nm-key[aria-pressed="false"] span:last-child { text-decoration: line-through; }
.nm-swatch { display: inline-block; width: 20px; height: 0; border-top: 2px solid var(--e); flex: none; }

/* line types (legend swatches and SVG paths share these) */
.nm-t-wan     { --e: #8a8f98; }
.nm-t-lan     { --e: #3f8fe0; }
.nm-t-tailnet { --e: #22a889; --dash: 6 4; }
.nm-t-public  { --e: #f08a24; }
.nm-t-uses    { --e: #9b72f2; --dash: 2 4; }
.nm-t-data    { --e: #b0855a; }
.nm-t-backup  { --e: #d9467e; --dash: 1 5; }
.nm-t-tailnet.nm-swatch { border-top-style: dashed; }
.nm-t-uses.nm-swatch, .nm-t-backup.nm-swatch { border-top-style: dotted; }

/* ---------------------------------------------------------------- board and lanes */
.nm-board { position: relative; }
.nm-lines { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.nm-lines-over { z-index: 2; }
.nm-edge {
  fill: none; stroke: var(--e); stroke-width: 1.5; stroke-linecap: round;
  stroke-dasharray: var(--dash, none); opacity: .55; transition: opacity .2s;
}
.nm-edge.is-lit { stroke-width: 2.25; opacity: .95; }
.nm-edge.is-dim { opacity: .1; }

.nm-layers { position: relative; z-index: 1; display: grid; gap: 44px; }
.nm-lane { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 20px; align-items: start; }
.nm-lane-head { padding-top: 10px; }
.nm-lane-head h3 {
  margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--nm-accent);
}
.nm-lane-head p { margin: 4px 0 0; font-size: 12px; color: var(--nm-muted); }

.nm-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.nm-row > .nm-card { flex: 1 1 150px; min-width: 150px; max-width: 250px; }
.nm-row > .nm-card.has-chips { flex: 1.7 1 250px; max-width: 360px; }

/* ---------------------------------------------------------------- cards */
.nm-card {
  position: relative; flex: 0 1 auto; min-width: 170px; max-width: 340px; padding: 12px 14px 12px;
  background: var(--nm-card); border: 1px solid var(--nm-border); border-radius: var(--nm-radius);
  box-shadow: var(--nm-shadow); transition: opacity .2s, border-color .2s;
}
.nm-card::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: -1px; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--c);
}
.nm-card-kicker {
  margin: 2px 0 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--nm-muted);
}

.nm-title {
  display: flex; align-items: center; gap: 10px; width: calc(100% + 8px); padding: 4px; margin: 0 -4px;
  text-align: left; background: none; border: 0; border-radius: 10px; cursor: pointer; transition: opacity .2s;
}
.nm-title + .nm-title { margin-top: 6px; }
.nm-title:hover, .nm-title:focus-visible { background: color-mix(in srgb, var(--c) 10%, transparent); outline: none; }
.nm-title.is-selected { background: color-mix(in srgb, var(--c) 16%, transparent); }
.nm-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; object-fit: cover;
  box-shadow: 0 0 0 2px var(--nm-card), 0 0 0 3.5px var(--c);
}
.nm-mono { display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff; background: var(--c); }
.nm-title-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.nm-name { font-weight: 700; font-size: 15px; }
.nm-sub { font-size: 12px; color: var(--nm-muted); }
.nm-meter {
  display: block; height: 5px; margin-top: 6px; border-radius: 3px; overflow: hidden;
  background: color-mix(in srgb, var(--nm-muted) 22%, transparent);
}
.nm-meter span { display: block; height: 100%; border-radius: 3px; background: var(--c); }

/* chips */
.nm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.nm-card-kicker + .nm-chips { margin-top: 0; }
.nm-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; font-size: 12.5px; line-height: 1.3;
  background: color-mix(in srgb, var(--c) 9%, transparent); border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
  border-radius: 999px; cursor: pointer; transition: background-color .15s, border-color .15s, opacity .2s;
}
.nm-chip:hover, .nm-chip:focus-visible { background: color-mix(in srgb, var(--c) 18%, transparent); border-color: var(--c); outline: none; }
.nm-chip.is-selected { background: var(--c); border-color: var(--c); color: #fff; }
.nm-chip.is-selected .nm-dot { background: #fff; }
.nm-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }

/* the server panel */
.nm-panel-card { max-width: none; padding: 16px 18px 18px; }
.nm-panel-head { display: flex; flex-wrap: wrap; gap: 8px 24px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--nm-border); }
.nm-panel-head .nm-title { width: auto; margin: 0; }
.nm-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px 22px; }
.nm-section-title {
  display: flex; align-items: center; gap: 7px; margin: 0 0 8px; font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--nm-muted);
}
.nm-section .nm-chips { margin-top: 0; }

/* focus: fade what isn't connected to the hovered or selected node */
.netmap.has-focus .nm-chip:not(.is-related),
.netmap.has-focus .nm-title:not(.is-related) { opacity: .3; }
.nm-chip.is-miss, .nm-title.is-miss { opacity: .2; }

.nm-caption { margin: 18px 0 0; font-size: 12px; color: var(--nm-muted); }

/* ---------------------------------------------------------------- details panel */
.nm-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; width: min(360px, calc(100vw - 32px));
  max-height: min(72vh, 580px); overflow: auto; padding: 18px 18px 16px;
  font-size: 14px; line-height: 1.45; color: var(--nm-ink); background: var(--nm-card);
  border: 1px solid var(--nm-border); border-top: 4px solid var(--c, var(--nm-accent)); border-radius: var(--nm-radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .28);
}
.nm-panel[hidden] { display: none; }
.nm-panel h3 { margin: 2px 32px 2px 0; font-size: 19px; line-height: 1.25; }
.nm-panel-sub { margin: 0 0 8px; font-size: 12.5px; color: var(--nm-muted); }
.nm-kicker { margin: 12px 0 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--nm-muted); }
.nm-panel > .nm-kicker:first-of-type { margin-top: 0; color: var(--c, var(--nm-accent)); }
.nm-about { margin: 0 0 8px; }
.nm-tabs { display: flex; gap: 4px; margin: 10px 0 12px; padding: 3px; border-radius: 10px; background: color-mix(in srgb, var(--nm-muted) 12%, transparent); }
.nm-tab {
  flex: 1; padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--nm-muted);
  background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.nm-tab:hover { color: var(--nm-ink); }
.nm-tab[aria-selected="true"] { color: var(--nm-ink); background: var(--nm-card); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.nm-tabpanel[hidden] { display: none; }
.nm-specs { margin-top: 0; row-gap: 7px; }
.nm-facts.nm-specs dd { font-family: inherit; font-size: 13px; }
.nm-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 13px; }
.nm-facts dt { color: var(--nm-muted); }
.nm-facts dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, "JetBrains Mono", monospace; font-size: 12px; }
.nm-panel ul.nm-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.nm-panel ul.nm-links li { margin: 0; }
.nm-panel ul.nm-links li::before { content: none; }
.nm-link {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 5px 6px; font-size: 13px;
  text-align: left; background: none; border: 0; border-radius: 6px;
}
button.nm-link { cursor: pointer; }
button.nm-link:hover { background: color-mix(in srgb, var(--nm-accent) 12%, transparent); }
.nm-close {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; font-size: 20px; line-height: 1;
  color: var(--nm-muted); background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.nm-close:hover { color: var(--nm-ink); background: color-mix(in srgb, var(--nm-muted) 14%, transparent); }
.nm-more { display: inline-block; margin-top: 12px; font-weight: 600; color: var(--nm-accent); }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 900px) {
  .nm-lane { grid-template-columns: 1fr; gap: 8px; }
  .nm-lane-head { padding-top: 0; }
  .nm-layers { gap: 28px; }
  .nm-lines { display: none; }   /* the panel's "Connects to" list carries the links */
  .nm-row .nm-card { flex: 1 1 200px; max-width: none; }
  .nm-panel { right: 8px; left: 8px; bottom: 8px; width: auto; max-height: 62vh; }
}
@media (prefers-reduced-motion: reduce) {
  .nm-edge, .nm-chip, .nm-card, .nm-title { transition: none; }
}

