/*
 * Copyright © 2025-26 l5yth & contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * The app is dark-only. These tokens are the (formerly ``body.dark``) dark
 * palette, promoted to ``:root`` so every element — including ``html`` itself —
 * resolves them; the previous light palette and its always-overridden
 * ``body.dark`` token block were removed with the light theme.
 */
:root {
  --bg: #0e1418;
  --bg2: #0e141b;
  --fg: #e6ebf0;
  --muted: #9aa7b4;
  --card: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #5fa8ff;
  --row-alt: rgba(255, 255, 255, 0.05);
  --table-head-bg: rgba(255, 255, 255, 0.06);
  --table-head-fg: var(--fg);
  --input-bg: #1e262c;
  --input-fg: var(--fg);
  --input-border: rgba(230, 235, 240, 0.24);
  --input-placeholder: rgba(230, 235, 240, 0.55);
  --control-accent: var(--accent);
  --announcement-bg: #3b2500;
  --announcement-fg: #ffd184;
  --announcement-border: #a56a00;
  --danger: #ff6b6b;
  /* Alias layer (SPEC UX3): names consumed by the federation styles resolve
     to the canonical tokens instead of silently failing (audit D-009). */
  --border: var(--line);
  --surface: var(--bg2);
  --table-header-bg: var(--table-head-bg);
  --hover-bg: var(--row-alt);
  --pad: 16px;
}

html {
  color-scheme: dark;
}

html,
body {
  background-color: var(--bg);
  color: var(--fg);
  transition: background-color 160ms ease, color 160ms ease;
}

a {
  color: var(--accent);
}

hr {
  border-color: var(--line);
}

.card,
.panel,
.box {
  background: var(--card);
  backdrop-filter: blur(2px);
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  border-collapse: collapse;
  width: 100%;
  border: 1px solid var(--line);
}

thead th {
  background: var(--table-head-bg);
  color: var(--table-head-fg);
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

tbody td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

tbody tr:nth-child(even) td {
  background: var(--row-alt);
}

.leaflet-container {
  background: transparent !important;
  color: var(--fg);
}

.neighbor-connection-line {
  cursor: pointer;
}

.trace-connection-line {
  stroke-dasharray: 6 6;
}

/*
 * Spider leader line drawn from each co-located marker back to its shared
 * coordinate.  Stroke uses the foreground token so the line stays visible
 * against both light and dark basemaps; opacity keeps it subdued enough to
 * read as a hint rather than a primary connection.  `pointer-events: none`
 * matches the `interactive: false` Leaflet option so the line never
 * intercepts clicks intended for the marker beneath it.
 */
.colocated-spider-line {
  stroke: var(--fg);
  stroke-width: 1;
  stroke-opacity: 0.5;
  stroke-dasharray: 1 1;
  fill: none;
  pointer-events: none;
}

/*
 * Asterisk + count badge that represents a collapsed (or expanded-but-still-
 * present) co-located node group.  The Leaflet ``L.divIcon`` host element
 * receives the ``.colocated-spider-hub`` class; the inner ``__glyph`` span
 * carries the visible circle so the cursor can still flip back to the
 * default state outside the badge.  Theming is delegated to the existing
 * ``--fg`` / ``--bg`` tokens so the badge blends with both light and dark
 * basemaps.
 */
.colocated-spider-hub {
  cursor: pointer;
  background: transparent;
  border: 0;
}

.colocated-spider-hub__glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--fg);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  user-select: none;
}

.leaflet-tooltip.trace-tooltip {
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--line);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  padding: 6px 8px;
  font-size: 13px;
}

.trace-tooltip__content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trace-tooltip__arrow {
  opacity: 0.7;
}

.neighbor-snr {
  margin-left: 4px;
  color: var(--muted);
  font-size: 12px;
}

body {
  font-family: system-ui, Segoe UI, Roboto, Ubuntu, Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: var(--pad);
  padding-bottom: calc(96px + var(--pad));
  gap: var(--pad);
}

.page-shell--full-screen {
  padding: 0;
  gap: var(--pad);
}

.page-shell--full-screen .site-header,
.page-shell--full-screen .app-footer {
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.page-shell--full-screen .site-header {
  padding-top: var(--pad);
}

.page-shell--full-screen .app-footer {
  padding-top: var(--pad);
  padding-bottom: var(--pad);
}

.page-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--pad);
  min-height: 0;
}

.page-main--dashboard {
  padding: 0;
}

.page-main--full-screen {
  padding: 0;
  gap: var(--pad);
}

h1 {
  margin: 0;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
  min-height: 56px;
  padding: 4px 0;
  margin-bottom: 8px;
}

.site-header__left,
.site-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-header__left {
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.site-header__right {
  flex: 0 0 auto;
  margin-left: auto;
}

.announcement-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 1.6em;
  padding: 0 var(--pad);
  border-radius: 999px;
  background: var(--announcement-bg);
  color: var(--announcement-fg);
  border: 1px solid var(--announcement-border);
  box-sizing: border-box;
  overflow: hidden;
}

.announcement-banner__content {
  margin: 0;
  line-height: 1.6;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-title {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.site-title__link {
  display: inline-flex;
  align-items: center;
  gap: inherit;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.site-title-text {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-title img {
  width: 36px;
  height: 36px;
  display: block;
  border-radius: 12px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.site-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--fg);
  text-decoration: none;
  border: 1px solid transparent;
  font-size: 14px;
}

.site-nav__link:hover {
  background: var(--card);
}

.site-nav__link.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
  font-weight: 600;
}

.site-nav__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Compound selector required: .icon-button { display: inline-flex } (below) shares
   the same specificity and appears later in the source, so it would otherwise win
   and keep the toggle permanently visible above the 900px breakpoint. */
.icon-button.menu-toggle {
  display: none;
}

.menu-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.mobile-menu[hidden] {
  display: none;
}

.mobile-menu__backdrop {
  flex: 1 1 auto;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 200ms ease;
}

.mobile-menu__panel {
  width: min(320px, 86vw);
  background: var(--bg2);
  color: var(--fg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 220ms ease;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.3);
}

.mobile-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-menu__title {
  margin: 0;
  font-size: 16px;
}

.mobile-menu__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-nav__link {
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--fg);
  text-decoration: none;
  border: 1px solid transparent;
}

.mobile-nav__link.is-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.mobile-nav__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mobile-menu.is-open {
  pointer-events: auto;
}

.mobile-menu.is-open .mobile-menu__backdrop {
  opacity: 1;
}

.mobile-menu.is-open .mobile-menu__panel {
  transform: translateX(0);
}

.menu-open {
  overflow: hidden;
}

.section-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
}

.section-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.section-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.meta {
  color: var(--muted);
  margin-bottom: 12px;
}

.instance-selector {
  display: flex;
  align-items: center;
}

.instance-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--input-bg);
  color: var(--input-fg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 6px 32px 6px 12px;
  font-size: 14px;
  line-height: 1.4;
  min-width: 220px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 4px), calc(100% - 12px) calc(50% - 4px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.instance-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .site-header {
    margin-bottom: 4px;
  }

  .site-header__left {
    flex-wrap: nowrap;
  }

  .site-nav {
    display: none;
  }

  .icon-button.menu-toggle {
    display: inline-flex;
  }

  .instance-selector {
    flex: 0 1 auto;
  }

  .instance-select {
    width: 100%;
  }

  .instance-select {
    min-width: 0;
  }
}


.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #444;
  font-size: 12px;
}

#map {
  position: relative;
  width: 100%;
  height: 60vh;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  display: block;
  border-color: #444;
}

.map-panel.is-fullscreen,
.map-panel:fullscreen,
.map-panel:-webkit-full-screen,
.map-panel:-moz-full-screen,
.map-panel:-ms-fullscreen,
#map.is-fullscreen,
#map:fullscreen,
#map:-webkit-full-screen,
#map:-moz-full-screen,
#map:-ms-fullscreen {
  width: 100vw;
  height: 100vh;
  min-width: 100vw;
  min-height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  border: none;
  border-radius: 0;
  background: #000;
}

.map-panel.is-fullscreen,
.map-panel:fullscreen,
.map-panel:-webkit-full-screen,
.map-panel:-moz-full-screen,
.map-panel:-ms-fullscreen {
  display: block;
}

.map-panel.is-fullscreen #map,
.map-panel:fullscreen #map,
.map-panel:-webkit-full-screen #map,
.map-panel:-moz-full-screen #map,
.map-panel:-ms-fullscreen #map,
#map.is-fullscreen,
#map:fullscreen,
#map:-webkit-full-screen,
#map:-moz-full-screen,
#map:-ms-fullscreen {
  height: 100vh !important;
  width: 100vw !important;
  min-height: 100vh;
  min-width: 100vw;
  max-height: 100vh;
  max-width: 100vw;
  border: none;
  border-radius: 0;
  flex: none;
}

.map-panel.is-fullscreen .map-toolbar,
.map-panel:fullscreen .map-toolbar,
.map-panel:-webkit-full-screen .map-toolbar,
.map-panel:-moz-full-screen .map-toolbar,
.map-panel:-ms-fullscreen .map-toolbar {
  top: 16px;
  right: 16px;
}

#map[data-map-status="placeholder"] {
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.08) 12px,
    rgba(255, 255, 255, 0.12) 12px,
    rgba(255, 255, 255, 0.12) 24px
  );
}

#map .map-placeholder-message {
  text-align: center;
  color: #ddd;
  font-size: 14px;
  line-height: 1.5;
  padding: 0 16px;
}

#map .map-placeholder-message strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
}

#map .map-placeholder-message span {
  display: block;
  margin-top: 4px;
}


#map .map-status-message {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  backdrop-filter: blur(6px);
  pointer-events: none;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(0, 0, 0, 0.65);
  color: #eee;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 1200;
  border-color: rgba(255, 255, 255, 0.16);
}



.map-toolbar button {
  background: rgba(36, 36, 36, 0.88);
  color: #f1f1f1;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.map-toolbar button:hover {
  background: rgba(52, 52, 52, 0.9);
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 0;
}

th,
td {
  padding: 4px 6px;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #222;
}

.mono {
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.row {
  display: flex;
  gap: var(--pad);
  align-items: center;
  justify-content: space-between;
}

.map-row {
  display: flex;
  gap: var(--pad);
  align-items: stretch;
}

.full-screen-section {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.map-panel--full {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.map-panel--full #map {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
}

.full-screen-section--map {
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}

.full-screen-section--map .map-panel {
  flex: 1 1 auto;
}

.view-map .page-main--full-screen {
  gap: 0;
}

.view-nodes .page-main--full-screen {
  gap: 0;
}

.view-map .full-screen-section--map {
  flex: 1 1 auto;
  display: flex;
}

.view-map .full-screen-section--map .map-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.view-map .full-screen-section--map .map-panel #map {
  flex: 1 1 auto;
  min-height: 0;
}

.view-nodes .full-screen-section--nodes {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.view-map .map-panel--full #map {
  height: 100%;
  min-height: 100%;
}

.chat-panel--full {
  flex: 1 1 auto;
  max-width: 100%;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.full-screen-section--chat .chat-panel {
  height: 100%;
}

body.view-chat {
  height: 100vh;
  overflow: hidden;
}

body.view-chat .page-shell {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.view-chat .page-main--full-screen {
  gap: 0;
}

.view-chat .full-screen-section--chat {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.view-chat .full-screen-section--chat .chat-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-panel--disabled {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--pad) calc(var(--pad) * 2);
  min-height: 50vh;
}

.chat-disabled-message {
  font-size: 1rem;
  color: var(--muted);
}

.nodes-table-wrapper {
  width: 100%;
}

.map-panel {
  position: relative;
  flex: 1 1 0%;
  min-width: 0;
  display: block;
}

.map-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 1300;
  pointer-events: none;
}

.map-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  line-height: 1.2;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease,
    box-shadow 160ms ease;
  pointer-events: auto;
}

.map-toolbar button:hover {
  background: rgba(245, 245, 245, 0.95);
}

.map-toolbar button svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
}

#mapFullscreenToggle .icon-fullscreen-exit {
  display: none;
}

#mapFullscreenToggle[aria-pressed='true'] .icon-fullscreen-exit {
  display: block;
}

#mapFullscreenToggle[aria-pressed='true'] .icon-fullscreen-enter {
  display: none;
}

.chat-panel {
  flex: 0 0 33%;
  max-width: 33%;
  height: 60vh;
  border: 1px solid #ddd;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 12px;
  background: #222;
  border-color: #444;
  color: #eee;
}

.chat-panel.chat-panel--full {
  flex: 1 1 auto;
  max-width: 100%;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Variant used inside the node detail page Messages section: full width,
   bounded height so the surrounding section does not turn into a single
   massive scroll.  The 60vh default of ``.chat-panel`` works for the
   dashboard sidebar but is too tall when stacked under telemetry charts. */
.chat-panel.chat-panel--node-detail {
  flex: 1 1 auto;
  max-width: 100%;
  width: 100%;
  height: auto;
  max-height: 60vh;
  min-height: 0;
}

/* Wrapper spans the full width and owns the bottom border so the arrow
   buttons are visually part of the tab bar. */
.chat-tablist-wrapper {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  border-bottom-color: rgba(255, 255, 255, 0.18);
}

.chat-tablist {
  display: flex;
  gap: 4px;
  padding: 6px 6px 0;
  flex: 1;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
}

.chat-tablist::-webkit-scrollbar {
  display: none; /* Chrome / Safari */
}

.chat-tab {
  flex: none; /* natural content width — no equal-stretch */
  white-space: nowrap;
  border: none;
  background: transparent;
  color: #ddd;
  padding: 6px 8px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 120ms ease, color 120ms ease;
  border-color: transparent;
}

/* Scroll arrow buttons flanking the tab list */
.chat-tab-scroll-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  background: #1a1a1a;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 10px;
  padding: 0;
  z-index: 1;
  transition: background-color 120ms ease;
}

.chat-tab-scroll-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.chat-tab-scroll-btn[hidden] {
  display: none;
}

/* Channel dropdown selector (SPEC LV8): a compact jump-to-channel control at the
   end of the tab bar. Mirrors the federation/region `.instance-select` chrome
   (theme tokens + a CSS-gradient triangle) so the two dropdowns match, sized down
   to sit beside the channel tabs. */
.chat-tab-select {
  flex: 0 0 auto;
  align-self: center;
  margin-left: 0.5rem;
  max-width: 11rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--input-bg);
  color: var(--input-fg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 4px 26px 4px 10px;
  font-size: 13px;
  line-height: 1.4;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 3px), calc(100% - 9px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.chat-tab-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-tab:is(:focus-visible, :hover) {
  background: rgba(255, 255, 255, 0.1);
}

.chat-tab.is-active {
  background: #222;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  border-bottom-color: var(--accent);
}

.chat-tabpanels {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.chat-tabpanel {
  flex: 1 1 auto;
  padding: 6px;
  overflow-y: auto;
  min-height: 0;
}

.chat-empty {
  margin: 12px 0;
  color: #888;
  font-style: italic;
}

.chat-entry-node {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
}

.chat-entry-copy {
  font-style: normal;
}

.chat-entry-reply {
  color: #999;
  font-style: italic;
  margin-right: 4px;
}

.chat-entry-msg {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: #bbb;
}

.chat-entry-date {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: bold;
  color: #bbb;
}

.short-name {
  display: inline-block;
  border-radius: 4px;
  padding: 0 2px;
}

.short-name[data-node-info] {
  cursor: pointer;
}

/* Touch target (audit follow-up c): the badge opens the node overlay on tap
   but is only ~15 px tall in the 12 px chat panel — under the 44 px mobile
   floor. On coarse pointers a transparent, centred ::after lifts the hit box
   to 44 px without changing the badge's look; fine pointers (mouse) keep the
   tight target so dense chat lines don't cross-capture clicks. */
@media (pointer: coarse) {
  .short-name[data-node-info] {
    position: relative;
  }

  .short-name[data-node-info]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    min-width: 44px;
    min-height: 44px;
    transform: translate(-50%, -50%);
  }
}

.short-info-overlay {
  position: absolute;
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  padding: 8px 10px 10px;
  font-size: 11px;
  line-height: 1.4;
  min-width: 200px;
  max-width: 240px;
  z-index: 20000;
  border-color: #444;
}

.short-info-overlay[hidden] {
  display: none;
}

.short-info-overlay .short-info-close {
  position: absolute;
  top: 4px;
  right: 4px;
  border: none;
  background: transparent;
  font-size: 14px;
  line-height: 1;
  padding: 2px;
  border-radius: 4px;
  cursor: pointer;
  color: inherit;
}

.short-info-overlay .short-info-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.short-info-sats {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: inherit;
  color: inherit;
  padding: 0;
  margin: 0;
  vertical-align: middle;
}

.short-info-sats__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.short-info-sats__glyph {
  display: block;
  filter: invert(1) grayscale(1);
}


.short-info-sats__count {
  font-family: inherit;
  font-size: inherit;
  letter-spacing: 0.1px;
}

.node-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 15000;
}

.node-detail-overlay[hidden] {
  display: none;
}

.node-detail-overlay__dialog {
  width: 90vw;
  height: 90vh;
  max-width: 1400px;
  max-height: 960px;
  background: var(--bg2);
  color: var(--fg);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  padding: 32px 24px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.node-detail-overlay__close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.node-detail-overlay__close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.node-detail-overlay__content {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
}

.node-detail-overlay__status {
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
}

.node-detail-overlay__status--error {
  color: var(--danger);
}




.charts-page {
  padding: 0 0 var(--pad);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.charts-page__intro {
  padding: 0 4px 12px;
}

.charts-page__intro h2 {
  margin: 0 0 6px;
  font-size: 1.6rem;
}

.charts-page__intro p {
  margin: 0;
  color: var(--muted);
}

.charts-page__content {
  min-height: 320px;
}

.charts-page__status {
  margin: 18px 0;
  font-size: 1rem;
  color: var(--muted);
}

.charts-page__status--error {
  color: var(--danger);
}

.node-detail {
  width: 100%;
  margin: 0;
  padding: 24px 0 40px;
}

.node-detail__header {
  margin-bottom: 12px;
  padding: 0 20px;
}

.node-detail__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 1.4rem;
}

.node-detail__badge {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.2rem;
}

.node-detail__table {
  margin: 20px 0 32px;
  overflow-x: auto;
}

.node-detail__table table {
  width: 100%;
}

.node-detail__charts {
  padding: 0 20px;
  margin: 12px 0 24px;
}

.node-detail__charts-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 640px), 1fr));
}

.node-detail__chart {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.node-detail__chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 1rem;
  margin: 0;
}

.node-detail__chart-header h4 {
  margin: 0;
  font-size: 1.2rem;
}

.node-detail__chart-header span {
  color: var(--muted);
  font-size: 1rem;
}

.node-detail__chart svg {
  width: 100%;
  height: auto;
  max-height: 420px;
}

.node-detail__chart-axis line {
  stroke: var(--line);
  stroke-width: 1;
}

.node-detail__chart-axis text,
.node-detail__chart-axis-label {
  fill: var(--muted);
  font-size: 0.95rem;
}

.node-detail__chart-grid-line {
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 1;
}


.node-detail__chart-point {
  stroke: none;
}

.node-detail__chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.node-detail__chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
}

.node-detail__chart-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.node-detail__chart-legend-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.node-detail__chart-legend-text small {
  color: var(--muted);
  font-size: 0.9rem;
}

.node-detail__identifier {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
}

.node-long-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.node-long-link:focus,
.node-long-link:hover {
  text-decoration-thickness: 2px;
}

.node-detail__status,
.node-detail__error,
.node-detail__noscript {
  margin: 16px 0;
  padding: 0 20px;
}

.node-detail__error {
  color: var(--danger);
}

.node-detail__content {
  display: grid;
  gap: 24px;
  padding: 0 20px;
}

.node-detail__neighbors-grid {
  display: grid;
  gap: 16px;
}

@media (min-width: 720px) {
  .node-detail__neighbors-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.node-detail__neighbors-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.node-detail__neighbors-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.node-detail__neighbors-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.node-detail__neighbors-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.node-detail__neighbor-snr {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
  font-size: 0.95rem;
}

.node-detail__trace-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.node-detail__trace {
  display: flex;
  align-items: center;
  gap: 10px;
}

.node-detail__trace-arrow {
  color: var(--muted);
  font-size: 0.95rem;
}

.node-detail__section h3 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.node-detail__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.node-detail__row {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  gap: 8px;
  margin-bottom: 6px;
}

.node-detail__row dt {
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}

.node-detail__row dd {
  margin: 0;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* Node detail spec sheet (SPEC PD1, Post-Deploy review 01): a single-record
   view is a spec sheet, not a table — grouped dt/dd (reusing .node-detail__row),
   nothing hidden, no horizontal scroll, reflowing to one column on mobile. */
.node-detail-sheet {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 40px;
}

.node-detail-sheet__group-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
}

@media (max-width: 659px) {
  .node-detail-sheet {
    grid-template-columns: 1fr;
  }
}

.node-detail__list li {
  margin-bottom: 4px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.short-info-content {
  margin: 0;
}

.meta-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 8px;
}

.meta-controls .filter-input {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  position: relative;
}

.filter-input input[type="text"] {
  flex: 1 1 auto;
  width: 100%;
  padding-right: 28px;
}

.filter-clear {
  position: absolute;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.filter-clear:hover {
  background: rgba(255, 255, 255, 0.12);
}


.filter-clear:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:not(.chat-tab):not(.sort-button) {
  padding: 6px 10px;
  border: 1px solid #ccc;
  background: #333;
  border-radius: 6px;
  cursor: pointer;
  color: #eee;
  border-color: #444;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.protocol-toggle-btn {
  width: auto;
  min-width: 32px;
  height: 32px;
  gap: 4px;
  padding: 0 6px;
  border: 1px solid #ccc;
  background: #333;
  border-radius: 6px;
  cursor: pointer;
  border-color: #444;
}

/* Per-protocol node count on the toggle (audit follow-up 04). Mirrors the
   legend column count (7-day active) so the same protocol shows the same
   number in both places. Hidden when empty so a countless button stays 32px. */
.protocol-toggle-count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--fg);
}

.protocol-toggle-count:empty {
  display: none;
}

.protocol-toggle-btn[aria-pressed="true"] {
  background: #2a2a2a;
}

.protocol-toggle-icon {
  display: block;
  transition: filter 0.15s ease;
}

button:not(.chat-tab):not(.sort-button):hover {
  background: #444;
}

.sort-button {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sort-button:hover {
  background: none;
}

.sort-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  color: inherit;
}

.sort-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sort-indicator {
  font-size: 0.75em;
  opacity: 0.6;
}

th[aria-sort] .sort-indicator {
  opacity: 1;
}

label {
  font-size: 14px;
  color: #ddd;
}

input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--input-fg);
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease,
    box-shadow 160ms ease;
}

input[type="text"]::placeholder {
  color: var(--input-placeholder);
}

input[type="text"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--control-accent);
  transition: accent-color 160ms ease, background-color 160ms ease;
}

/* Wrapper that places the toggle button to the LEFT of the legend panel. */
.legend-outer {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 4px;
  /* Reset Leaflet control chrome so only the inner elements have styling. */
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.legend {
  position: relative;
  background: #333;
  color: #eee;
  padding: 8px 10px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 12px;
  line-height: 18px;
  min-width: 160px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  border-color: #444;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  margin-bottom: 6px;
  font-weight: 600;
}

.legend-title {
  font-size: 13px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-items--columns {
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
}

.legend-column {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.legend-protocol-count {
  font-weight: 400;
  opacity: 0.7;
}

.legend-column-header {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 11px;
  padding: 2px 6px 4px;
  color: var(--fg);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  cursor: pointer;
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.legend-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.legend-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The `button` prefix is required (Legend & Chat Fix): a role chip is a
   <button>, and the reset `button:not(.chat-tab):not(.sort-button)` is
   specificity (0,2,1). The bare `.legend-item[aria-pressed="true"]` is (0,2,0)
   and lost to it, so the selected state never painted (every chip computed to
   #333, only font-weight surviving). `button.legend-item[aria-pressed="true"]`
   is (0,2,1) and, later in source, wins. */
button.legend-item[aria-pressed="true"] {
  border-color: #70b3f0;
  background: rgba(91, 155, 213, 0.48);
  color: #c8e8ff;
  font-weight: 600;
}

/* Role swatch = the marker at legend size (Legend & Chat Fix): colour keys
   role, shape keys protocol. Both carry the marker's 1px ring; the shape
   variants below add the circle / rotated-diamond geometry. */
.legend-swatch {
  display: inline-block;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.7);
  border-radius: 2px;
}

/* Meshtastic — the circle marker at legend size. */
.legend-swatch--circle {
  border-radius: 50%;
}

/* MeshCore — the rotated-diamond chip at legend size. Equal optical area to the
   circle (the map's `side = radius × 1.78` → an 11px square ≈ a 12px circle),
   rotated 45° with the chip's 3px corners. The 2px side margin gives it a 16px
   slot so the ~15.6px diagonal never clips the label. */
.legend-swatch--diamond {
  width: 11px;
  height: 11px;
  margin: 0 2px;
  border-radius: 3px;
  transform: rotate(45deg);
}

.protocol-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 2px;
}

.nav-protocol-icon {
  margin-right: 3px;
}

.legend-hidden {
  display: none !important;
}

.legend-toggle {
  margin-top: 8px;
}

.legend-toggle-button {
  font-size: 12px;
  color: #eee;
  background: #333;
  border-color: #444;
}

/*
 * Single dimming veil over the whole tile pane. `0.5625 = 0.75 × 0.75` is the
 * *effective* brightness the map rendered at before the basemap became two
 * stacked layers (the pane and each layer were each dimmed 0.75, multiplying).
 * Dimming once at the pane — with the layers themselves left opaque — makes the
 * result independent of how many layers are in the pane (the CARTO base, the HOT
 * overlay, and, on the dashboard, a possible offline placeholder), so the stack
 * composites to exactly that same brightness.
 */
#map .leaflet-tile-pane {
  opacity: 0.5625;
}

/*
 * Both basemap providers are natively colourful, light-background raster maps
 * (HOT overlay over a CARTO Voyager base). This one static filter greys and
 * inverts them to match the dark UI, applied identically to the HOT layer
 * (`.map-tiles-hot`) and the CARTO base layer (`.map-tiles-fallback`) so a
 * viewport mixing an arrived HOT tile and a not-yet-arrived cell (CARTO showing
 * through) renders as one coherent dark basemap instead of a light/dark
 * checkerboard. Leaflet stamps a layer's `className` on its container
 * (`.leaflet-layer`), and `filter` on the container greys that provider's whole
 * tile set as a group — so these per-layer classes carry the filter. Offline
 * placeholder tiles carry neither class and stay unfiltered.
 */
#map .leaflet-layer.map-tiles-hot,
#map .leaflet-layer.map-tiles-fallback {
  filter: grayscale(1) invert(1) brightness(0.9) contrast(1.08);
  -webkit-filter: grayscale(1) invert(1) brightness(0.9) contrast(1.08);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #333;
  color: #eee;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.8);
}

#nodes {
  font-size: 12px;
}

.nodes-col--protocol {
  width: 20px;
  min-width: 20px;
  text-align: center;
  padding-inline: 4px;
}

.app-footer {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  box-sizing: border-box;
  background: #222;
  border-top: 1px solid #444;
  color: #eee;
  font-size: 12px;
  z-index: 4100;
  /* Lift the fixed footer over long scrolling pages (audit follow-up 08): the
     opaque chrome now renders on every route, so a soft top shadow separates
     it from body copy that scrolls beneath it. */
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}

.app-footer .footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 auto;
  width: 100%;
  max-width: 960px;
  padding: 6px var(--pad);
  text-align: center;
  box-sizing: border-box;
}

/* Dot separators (Post-Deploy review 03): a dot wants a touch more air and less
   weight than an em dash. */
.app-footer .footer-separator {
  margin: 0 5px;
  color: var(--muted);
}

/* The links are their own footer tier (Post-Deploy review 02): flex-basis 100%
   drops them onto their own line inside the wrapping .footer-content, so the row
   can no longer strand the version→links separator at the end of line one. */
.app-footer .footer-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  flex-basis: 100%;
}

.app-footer .footer-brand {
  font-weight: 600;
}

.app-footer a {
  color: inherit;
}

/* The slim (transparent, borderless) footer variant is retired (audit
   follow-up 08): it left the still-`position: fixed` footer floating without a
   background over the scrolling body copy on Charts, Federation and /pages/*.
   Every route now uses the one opaque `.app-footer` chrome above. */

.meta-active-nodes {
  font-size: 0.85em;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .app-footer .footer-content {
    padding: 10px 12px;
    justify-content: center;
    gap: 4px 8px;
  }

  .app-footer .footer-links {
    flex-direction: column;
    gap: 4px;
  }

  .app-footer .footer-separator {
    display: none;
  }
}


@media (max-width: 1024px) {
  .row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--pad);
  }

  .site-title img {
    width: 44px;
    height: 44px;
  }

  .map-row {
    flex-direction: column;
  }

  .meta-controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .meta-controls .filter-input {
    flex: 1 1 100%;
    order: -1;
  }

  #map {
    order: 1;
    width: 100%;
    max-width: 100%;
    height: 50vh;
  }

  .chat-panel {
    order: 2;
    flex: none;
    max-width: 100%;
    height: 30vh;
  }

  .legend {
    max-width: min(240px, 80vw);
  }
}

@media (max-width: 1679px) {
  .nodes-col--node-id,
  .nodes-col--frequency,
  .nodes-col--modem-preset {
    display: none;
  }
}

@media (max-width: 1559px) {
  .nodes-col--temperature,
  .nodes-col--humidity,
  .nodes-col--pressure {
    display: none;
  }
}

@media (max-width: 1319px) {
  .nodes-col--latitude,
  .nodes-col--longitude,
  .nodes-col--last-position {
    display: none;
  }
}

@media (max-width: 1109px) {
  .nodes-col--voltage,
  .nodes-col--air-util-tx,
  .nodes-col--altitude {
    display: none;
  }
}

@media (max-width: 899px) {
  .nodes-col--uptime,
  .nodes-col--frequency,
  .nodes-col--modem-preset {
    display: none;
  }
}

@media (max-width: 659px) {
  /* Curated mobile survivors (SPEC UX9): Protocol/Short/Long/Last Seen/
     Battery. Role hides; Battery is the operator's column. */
  .nodes-col--role,
  .nodes-col--channel-util,
  .nodes-col--hw-model {
    display: none;
  }
}















.protocol-toggle-btn:hover {
  background: #444;
}








.legend-toggle-button:hover {
  background: #444;
}









/* ===========================
   Federation Page Styles
   =========================== */

.header-federation {
  display: flex;
  align-items: center;
  gap: 12px;
}

.federation-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background-color 160ms ease, transform 160ms ease;
}

.federation-link:hover {
  background: var(--hover-bg, rgba(255, 255, 255, 0.1));
  transform: scale(1.1);
}

.federation-page {
  padding: 0 0 var(--pad);
  max-width: none;
  margin: 0;
  width: 100%;
}

.federation-page__content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.federation-page__map-row {
  width: 100%;
  height: 400px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.federation-page__map-row .map-panel {
  height: 100%;
}

.federation-page__map-row #map {
  height: 100%;
  width: 100%;
}

.instances-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

#instances {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

#instances th,
#instances td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

#instances th {
  font-weight: 600;
  background: var(--table-header-bg, var(--surface));
  position: sticky;
  top: 0;
  z-index: 1;
}

#instances tbody tr:hover {
  background: var(--hover-bg, rgba(255, 255, 255, 0.05));
}

#instances a {
  color: var(--accent);
  text-decoration: none;
}

#instances a:hover {
  text-decoration: underline;
}

.instances-col--name {
  min-width: 140px;
}

.instances-col--domain {
  min-width: 180px;
}

.instances-col--contact {
  min-width: 160px;
  white-space: pre-wrap;
  word-break: break-word;
}

.instances-col--version {
  min-width: 80px;
}

.instances-col--channel,
.instances-col--frequency {
  min-width: 100px;
}

.instances-col--nodes {
  min-width: 110px;
}

.instances-col--latitude,
.instances-col--longitude {
  min-width: 100px;
}

.instances-col--last-update {
  min-width: 90px;
}

@media (max-width: 900px) {
  .federation-page__map-row {
    height: 300px;
  }

  .header-federation {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .federation-link {
    align-self: flex-end;
  }
}

/* ── Static pages (markdown content) ────────────────────────── */

.static-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 16px;
}

.static-page__content.markdown-body {
  color: var(--fg);
  line-height: 1.7;
  font-size: 15px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--fg);
  margin: 1.6em 0 0.6em;
  font-weight: 600;
  line-height: 1.3;
}

.markdown-body h1 { font-size: 1.6em; }
.markdown-body h2 { font-size: 1.3em; border-bottom: 1px solid var(--line); padding-bottom: 0.3em; }
.markdown-body h3 { font-size: 1.1em; }
.markdown-body h4 { font-size: 1em; }

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body p {
  margin: 0.8em 0;
}

.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.markdown-body a:hover {
  opacity: 0.85;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.8em 0;
  padding-left: 1.8em;
}

.markdown-body li {
  margin: 0.3em 0;
}

.markdown-body blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 3px solid var(--accent);
  background: var(--bg2);
  border-radius: 4px;
  color: var(--muted);
}

.markdown-body blockquote p {
  margin: 0.4em 0;
}

.markdown-body code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.9em;
  background: var(--bg2);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.markdown-body pre {
  margin: 1em 0;
  padding: 12px 16px;
  background: var(--bg2);
  border-radius: 6px;
  overflow-x: auto;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.5;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.9em;
}

.markdown-body th,
.markdown-body td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

.markdown-body th {
  background: var(--bg2);
  font-weight: 600;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

@media (max-width: 600px) {
  .static-page {
    padding: 20px 12px;
  }

  .markdown-body h1 { font-size: 1.3em; }
  .markdown-body h2 { font-size: 1.15em; }
}

/* Live-update highlight (SPEC LV1/LV2/LV3, amends VF5): a ~1.2s fade applied to a
   node row / chat message row when a live SSE update lands on it. It starts
   white, fades through the element's role colour (the --flash-role-color custom
   property stamped at render time) with increasing transparency, then clears.
   An inset box-shadow overlay means there is no layout shift; each element runs
   its own animation, so concurrent updates stack independently (LV2). */
@keyframes live-flash-fade {
  0% { box-shadow: inset 0 0 0 100vmax rgba(255, 255, 255, 0.9); }
  30% { box-shadow: inset 0 0 0 100vmax var(--flash-role-color, rgba(255, 255, 255, 0.55)); }
  100% { box-shadow: inset 0 0 0 100vmax transparent; }
}

.live-flash {
  animation: live-flash-fade 1.2s ease-out;
}

/* Map-marker wave (SPEC LV5): an expanding ring emitted from a flashed marker.
   The ring grows from ~12px radius and fades toward the role colour over ~1.2s.
   Rendered as a Leaflet divIcon, so it is a positioned overlay with no layout
   shift; the marker layer removes it after the animation completes. */
@keyframes live-flash-wave {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(3.5); opacity: 0; }
}

.live-flash-wave {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--flash-role-color, rgba(255, 255, 255, 0.85));
  pointer-events: none;
  animation: live-flash-wave 1.2s ease-out forwards;
}

/* Honor reduced-motion: data still updates live, only the highlight/wave is
   withheld. */
@media (prefers-reduced-motion: reduce) {
  .live-flash,
  .live-flash-wave {
    animation: none;
  }

  /* Motion the LV9 gate never covered (SPEC UX11, audit D-036): Leaflet's
     zoom easing and the chat tab strip's smooth scrolling. */
  .leaflet-zoom-anim .leaflet-zoom-animated {
    transition: none !important;
  }

  .chat-tablist {
    scroll-behavior: auto;
  }
}

/* ===========================
   UX audit remediation (SPEC UX2–UX14)
   =========================== */

/* Degenerate-state voice (UX4, D-001): the noscript notice and the
   server-rendered waiting row must read as "waiting", not as a broken UI. */
.noscript-notice {
  margin: 0;
  padding: 10px var(--pad);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  color: var(--fg);
}

/* Condensed nodes table (audit follow-up 06): the generic `th, td` padding is
   shadowed by the unscoped `thead th` / `tbody td` 8px rules, so row density is
   scoped to #nodes here — ~20px rows instead of 30px (a third more nodes per
   screen) without shrinking the 12px type. */
#nodes thead th {
  padding: 5px 8px;
}

#nodes tbody td {
  padding: 3px 8px;
  line-height: 1.35;
}

#nodes .nodes-group-header th {
  padding: 3px 8px;
}

/* The waiting row keeps generous padding. It is inside #nodes tbody, so the
   tight `#nodes tbody td` rule above would otherwise apply — an id-scoped
   selector is needed to outrank it (a bare `.nodes-empty-row td` class would
   lose to the id). */
.nodes-empty-row td {
  color: var(--muted);
  font-style: italic;
}

#nodes .nodes-empty-row td {
  padding: 12px 8px;
}

/* Absent table values render the overlay's muted dash (UX4, D-020). */
.cell-empty {
  color: var(--muted);
}

/* Freshness buckets (UX5, D-005): stale rows dim, live rows carry a 3 px
   accent rule on their first cell; text stays fully readable via opacity on
   the cells, not the row background. */
#nodes tbody tr[data-age="stale"] > td {
  opacity: 0.55;
}

#nodes tbody tr[data-age="live"] > td:first-child {
  box-shadow: inset 3px 0 0 0 var(--accent);
}

/* Row affordance (UX9, D-017): rows respond to hover and read as clickable;
   the waiting and disclosure rows opt out. */
#nodes tbody tr:not(.node-extra):not(.nodes-empty-row):hover > td {
  background: var(--hover-bg);
  cursor: pointer;
}

/* Numeric columns (UX9, D-023): right-aligned tabular mono so vertical
   comparison works; headers share the alignment. */
#nodes td.num,
#nodes th.num {
  text-align: right;
}

#nodes td.num {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* Grouped header row (UX9, D-006): quiet group scent above the columns.
   Both header rows pin (audit follow-up b): the base `th` rule already sticks
   the column row at top:0, so the group row must stick too — otherwise it
   scrolls away and leaves the column row floating unbacked on the /nodes page.
   The group row pins at the top and the column row just beneath it. The group
   th uses border-box + a fixed height so the column row's offset is exact
   despite the page's non-global box-sizing. */
.nodes-group-header th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #222;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 3;
  box-sizing: border-box;
  /* The 24px height and the column row's `top: 24px` below are a coupled pair
     (Post-Deploy review, "fragile"): keep the group row exactly one line tall
     so the two sticky rows can never overlap. `white-space: nowrap` stops a
     longer label, a translation, or a narrow tier from wrapping the group row
     and breaking that invariant. */
  height: 24px;
  white-space: nowrap;
}

/* Column header row pins directly below the 24px group row (see above). */
#nodes thead tr:not(.nodes-group-header) th {
  top: 24px;
  z-index: 2;
}

.nodes-group-header th:first-child {
  border-left: none;
}

/* Mobile disclosure column (UX9, D-007): hidden while every column fits,
   revealed as soon as the first responsive tier hides data. */
.nodes-col--more {
  width: 32px;
  min-width: 32px;
  text-align: center;
  display: none;
  padding-inline: 2px;
}

@media (max-width: 1679px) {
  .nodes-col--more {
    display: table-cell;
  }
}

.node-extra-toggle {
  min-width: 24px;
  min-height: 24px;
  border-radius: 6px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.node-extra > td {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.node-extra__list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 12px;
  margin: 6px 0;
}

.node-extra__list dt {
  color: var(--muted);
}

.node-extra__list dd {
  margin: 0;
}

/* Disclosure-row fallback when a node reported none of the hidden fields
   (audit follow-up 07). */
.node-extra__empty {
  margin: 6px 0;
  color: var(--muted);
  font-style: italic;
}

/* Join strip (UX12, D-002; audit follow-up 04): the radio settings a newcomer
   needs, moved from the meta row to the footer. */
.join-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85em;
  color: var(--muted);
}

.join-line__entry {
  overflow: hidden;
  text-overflow: ellipsis;
}

.join-line__proto {
  color: var(--fg);
}

/* Footer placement: centre the strip and let it wrap on narrow viewports
   rather than clipping the way the single-line meta row did. */
.footer-join {
  justify-content: center;
  flex-wrap: wrap;
  overflow: visible;
  white-space: normal;
  padding: 6px var(--pad) 0;
}

.footer-join .join-line__entry {
  overflow: visible;
}

/* Live/paused control (UX6, D-010): visible text state — accent while the
   stream is live, muted while frozen. */
#autorefreshToggle {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  white-space: nowrap;
}

#autorefreshToggle[aria-pressed="false"] {
  color: var(--accent);
}

#autorefreshToggle[aria-pressed="true"] {
  color: var(--muted);
}

/* Promoted day count in the vital-sign line (UX11, D-026). */
.meta-active-nodes__today {
  color: var(--fg);
  font-weight: 600;
}

/* MeshCore marker chips (UX7, D-013; audit follow-up 03): shape encodes
   protocol. The fill is a round(radius × 1.78) square rotated 45° into an
   equal-area diamond with rounded corners; the rotated diagonal exceeds the
   divIcon box, so the container keeps overflow visible. */
.node-marker-chip {
  background: transparent;
  border: none;
  overflow: visible;
}

.node-marker-chip__fill {
  display: block;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.7);
  border-radius: 3px;
  transform: rotate(45deg);
}

/* Legend line-style key (UX7, D-014). */
.legend-line-sample {
  vertical-align: middle;
  margin-right: 4px;
}

/* Colocated hub (UX11, D-031): 32 px hit box centring the 16 px glyph. */
.colocated-spider-hub {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Region selector behind a compact toggle (UX11, D-029). */
.instance-selector {
  gap: 6px;
}

/* Region toggle (audit follow-up 02): 🌍 reads as a place where the old 🌐 read
   as a generic "web" glyph. It sits greyscale/dimmed by default so it stays out
   of the header's colour budget, then returns to full colour on hover and while
   open — the colour is the open-state feedback the toggle otherwise lacked
   (aria-expanded already flips, so no JS change). The transparent border gives
   the open state an accent frame. */
.instance-selector-toggle {
  font-size: 17px;
  filter: grayscale(1);
  opacity: 0.72;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: filter 140ms ease, opacity 140ms ease;
}

.instance-selector-toggle:hover,
.instance-selector-toggle[aria-expanded="true"] {
  filter: none;
  opacity: 1;
}

.instance-selector-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--input-bg);
}

/* Site title clamp (UX11, D-015): long instance names shrink and ellipsize
   instead of colliding with the nav or the hamburger. */
.site-title {
  font-size: clamp(18px, 2.2vw, 28px);
}

.site-title-text {
  max-width: 40vw;
}

/* Chat hanging indent (UX11, D-033; audit follow-up a): the line prefix
   `[HH:MM:SS][freq][MF]` is 19 characters, so the hang is 19ch — wrapped log
   lines land under the message column instead of mid-timestamp (the old 8ch
   stopped inside the clock). */
.chat-entry-msg,
.chat-entry-node {
  padding-left: 19ch;
  text-indent: -19ch;
  /* Break unbreakable tokens (Legend & Chat Fix): `.chat-tabpanel` is
     `overflow-y: auto`, so its x-axis computes to `auto` — a horizontal scroll
     container. Nothing else in base.css breaks long tokens, so one hex payload,
     long URL, or 39-char long name overflows the panel. `anywhere` (not
     `break-word`) also lowers the entry's min-content width, so it can never
     demand more width than the panel — wrapped fragments continue under the
     19ch hang. No `overflow-x: hidden`, which would only mask the next
     regression. */
  overflow-wrap: anywhere;
}

/* text-indent is inherited, so the hanging indent re-applies to the inline
   badge, protocol icon and reply prefix nested in the line and shoves them out
   of their colour box (audit follow-up 01). Zero it back on those descendants;
   :where() keeps the reset at specificity 0 so nothing has to fight it. */
:where(.chat-entry-msg, .chat-entry-node)
  :where(.short-name, .protocol-icon, .chat-entry-reply) {
  text-indent: 0;
}

/* Chat date dividers separate days spatially (UX11, D-040). */
.chat-entry-date {
  border-top: 1px solid var(--line);
  padding-top: 4px;
  margin-top: 6px;
}

/* Mobile chat channel navigation is the dropdown alone (UX11, D-025):
   the fiddly 12 px tab strip and its 28 px arrows hide ≤ 900 px. */
@media (max-width: 900px) {
  .chat-tablist,
  .chat-tab-scroll-btn {
    display: none;
  }
}

/* Announcement banner wraps on narrow screens (UX11, D-030). */
@media (max-width: 600px) {
  .announcement-banner {
    height: auto;
    max-height: 4.8em;
  }

  .announcement-banner__content {
    white-space: normal;
  }
}

/* Federation table: coordinates fold away on narrow viewports (UX9, D-032). */
@media (max-width: 1319px) {
  .instances-col--latitude,
  .instances-col--longitude {
    display: none;
  }
}

/* Zebra striping for the nodes table is class-driven (SPEC UX9): the hidden
   disclosure rows occupy nth-child slots, so structural even/odd would stop
   alternating visible rows. :where() keeps the neutralizer's specificity
   below the class-driven stripe and the disclosure row's card background. */
#nodes tbody :where(tr:nth-child(even)) > td {
  background: none;
}

#nodes tbody tr.row-alt > td {
  background: var(--row-alt);
}

#nodes tbody tr.node-extra > td {
  background: var(--card);
}
