/* netmapper UI. Dark for everyone by default; the header toggle switches to
   the light theme, which theme.js puts on <html> as data-theme="light" before
   the first paint. The visitor's OS preference is deliberately not consulted. */

:root {
  --bg: #11151c;
  --panel: #171d26;
  --panel-2: #1e2633;
  --line: #2a3442;
  --text: #e6ebf2;
  --muted: #98a4b5;
  --accent: #4da3ff;
  --danger: #e06666;
  --ok: #3fbf7f;
  --radius: 8px;
  --bar-height: 52px;
  /* Chart marks. One hue per scheme, chosen for each surface rather than
     flipped automatically; the hover step is lighter on dark, darker on
     light, so it always moves away from the surface. */
  --chart-bar: #3987e5;
  --chart-bar-active: #6aa7f0;
  --chart-track: color-mix(in srgb, var(--chart-bar) 16%, transparent);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --line: #d7dfea;
  --text: #17202c;
  --muted: #5b6878;
  --accent: #1667c9;
  --danger: #b3261e;
  --ok: #1f8a5b;
  --chart-bar: #2a78d6;
  --chart-bar-active: #1c5cab;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

/* --- header --------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--bar-height);
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 2;
}

.wordmark {
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  font-size: 17px;
}
.wordmark:hover { text-decoration: none; color: var(--accent); }

.stats {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

/* Filled by app.js once clerk-js has settled, so it is empty on first paint
   and must take up no room until it is not. */
.auth {
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth:empty { display: none; }

.who {
  color: var(--muted);
  font-size: 13px;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The primary navigation. The current page is marked by weight, a filled
   background and an underline, so it does not rest on colour alone. The
   selectors name the element: .primary on its own is also the primary
   button style. */
nav.primary {
  display: flex;
  align-items: center;
  gap: 2px;
}
nav.primary a {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
nav.primary a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
nav.primary a[aria-current="page"] {
  color: var(--text);
  font-weight: 650;
  background: var(--panel-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}
nav.primary[hidden] { display: none; }

@media (max-width: 640px) {
  .who { display: none; }
  .stats { font-size: 12px; }

  /* Four links, the wordmark and the account corner do not share one row at
     phone width, so the links drop to a row of their own. */
  .topbar { flex-wrap: wrap; row-gap: 0; padding: 6px 12px; }
  .topbar .stats { display: none; }
  nav.primary {
    order: 3;
    width: 100%;
    overflow-x: auto;
    margin: 0 -6px;
  }
  nav.primary a { padding: 6px 8px; }
}

form.inline { display: inline; margin: 0; }

/* --- buttons and fields --------------------------------------------------- */

.button,
button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 12px;
}
.button:hover, button:hover { border-color: var(--accent); text-decoration: none; }

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 600;
}
.button.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }

.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-decoration: none;
}
.linkish:hover { text-decoration: underline; }
.linkish.danger { color: var(--danger); }

/* The theme switch in the header. It reads as a quiet link, like the
   account links beside it. */
.theme-toggle { color: var(--muted); font-size: 13px; }
.theme-toggle:hover { color: var(--text); }
.theme-toggle[hidden] { display: none; }

textarea {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--text) !important;
  font-size: 14px !important;
}
label.check input { margin: 3px 0 0; accent-color: var(--accent); }
.optional { color: var(--muted); font-weight: 400; }
input[aria-invalid="true"] { border-color: var(--danger); }

input[type="text"],
input[type="email"],
input[type="password"] {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- pages ---------------------------------------------------------------- */

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}
.page.narrow { max-width: 420px; }
.page.wide { max-width: 1100px; }

h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 32px 0 10px; }
.lede { color: var(--muted); margin: 0 0 20px; }
/* A group's description comes from a textarea; its line breaks are kept. */
.lede.description { white-space: pre-line; overflow-wrap: anywhere; }
.footnote { color: var(--muted); margin-top: 20px; font-size: 14px; }
.hint-text { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.empty { color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 6px; }
.stack label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.stack .button { margin-top: 18px; }

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.row input[type="text"] { flex: 1 1 220px; width: auto; }

.error {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border: 1px solid var(--danger);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 12px;
  margin: 0 0 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- new key -------------------------------------------------------------- */

.newkey {
  background: var(--panel);
  border: 1px solid var(--ok);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
}
.newkey h2 { margin: 0 0 4px; font-size: 16px; }
.newkey p { margin: 0 0 10px; color: var(--muted); }

.keyrow {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.keyrow code {
  flex: 1 1 320px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  word-break: break-all;
  user-select: all;
}

/* --- tables --------------------------------------------------------------- */

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
  /* A scroller must be positioned to clip what is absolutely positioned
     inside it, such as a .visually-hidden label in a cell; otherwise that
     label is placed against the page and widens it at phone sizes. */
  position: relative;
}
.grid th, .grid td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.grid th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.grid td.right, .grid th.right { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr.muted td { color: var(--muted); }

.badge {
  display: inline-block;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  color: var(--muted);
}

.status { font-size: 12px; }
.status-done { color: var(--ok); }
.status-failed { color: var(--danger); }
.status-queued, .status-processing { color: var(--muted); }

/* --- API docs ------------------------------------------------------------- */

/* The API link sits with the account links and reads like them. */
.nav-docs { color: var(--muted); font-size: 13px; }
.nav-docs:hover, .nav-docs[aria-current="page"] { color: var(--text); }

.docs h3 { font-size: 15px; margin: 22px 0 8px; }
.docs ul, .docs ol { padding-left: 22px; }
.docs li + li { margin-top: 4px; }

.toc {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 8px;
  font-size: 14px;
}
.toc ol { margin: 0; }
.toc ol ol { margin-top: 4px; columns: 2 18rem; column-gap: 24px; }

/* Code a reader will copy: its own panel, scrolled rather than wrapped, so a
   command stays one command. */
pre.code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 8px 0 14px;
  overflow-x: auto;
  line-height: 1.45;
}
pre.code code { font-size: 13px; }

.endpoint {
  border-top: 1px solid var(--line);
  padding-top: 4px;
  margin-top: 18px;
}
.endpoint h3 code { font-size: 15px; }
.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 2px 14px;
  margin: 10px 0;
  font-size: 14px;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.example summary { cursor: pointer; color: var(--accent); font-size: 14px; }
/* The docs' tables are prose, not figures: their cells wrap to the page
   rather than scrolling sideways, except the first, which names a code,
   parameter or bucket and reads best on one line. */
.grid.prose { white-space: normal; }
.grid.prose td { vertical-align: top; }
.grid.prose td:first-child { white-space: nowrap; }
/* Words wrap at spaces; a long bit of code such as a JSON body may break
   anywhere, so it cannot push a phone-width table past the screen. */
.grid.prose td code { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .grid.prose th, .grid.prose td { padding-left: 6px; padding-right: 6px; }
}

/* --- upload page ---------------------------------------------------------- */

/* The drop zone reads as a target: a dashed edge that lights up with the
   accent while a file is dragged over it. */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 24px 16px;
  text-align: center;
}
.dropzone.is-dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}
.dropzone p { margin: 0 0 10px; }
.dropzone .hint-text { margin: 12px auto 0; max-width: 60ch; }
.dropzone-title { font-weight: 600; }

/* One row per file: name, size, a progress bar and what is happening. On a
   phone the status drops below the rest rather than squeezing the name. */
.upload-queue {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.upload-queue:empty { display: none; }
.upload-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(80px, 160px);
  grid-template-areas: "name size bar" "status status status";
  gap: 4px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.upload-name {
  grid-area: name;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.upload-size { grid-area: size; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.upload-item progress { grid-area: bar; width: 100%; accent-color: var(--accent); }
.upload-status { grid-area: status; color: var(--muted); font-size: 13px; }
.upload-item.is-done .upload-status { color: var(--ok); }
.upload-item.is-failed .upload-status { color: var(--danger); }
.upload-item.is-failed { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.upload-item.is-waiting .upload-status { color: var(--text); }

/* A table that should span its container. .grid on its own is a scrolling
   block, so the scrolling moves to a wrapper and the table stays a table. */
.table-scroll { overflow-x: auto; position: relative; }
.grid.full { display: table; white-space: normal; }
.grid.full td, .grid.full th { white-space: nowrap; }
/* Cells holding someone's name may wrap, so a long group name or a "(you)"
   tag does not push the figures a board is ranked by off a phone's screen.
   A group name is free text and may be one long word, so it may break
   anywhere; a handle is at most 24 characters and only wraps at spaces. */
.grid.full td.wrap { white-space: normal; }
.grid.full td.wrap .handle { white-space: nowrap; }
.grid.full td.wrap.name { overflow-wrap: anywhere; min-width: 6em; }
@media (max-width: 480px) {
  .grid.full th, .grid.full td { padding-left: 6px; padding-right: 6px; }
}

/* The viewer's own row on a board or a member list. The bar on the left and
   the "(you)" text carry it as well as the tint. */
.grid tr.you td,
.grid tr.you th { background: color-mix(in srgb, var(--accent) 13%, transparent); font-weight: 650; }
.grid tr.you > :first-child { box-shadow: inset 3px 0 0 var(--accent); }
.you-tag { color: var(--muted); font-weight: 500; }
.grid tr.gap td { color: var(--muted); text-align: center; padding: 2px 10px; }

/* --- stats pages ---------------------------------------------------------- */

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 28px 0 10px;
}
.section-head h2 { margin: 0; }

/* Link tabs, drawn as a segmented control. */
.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  margin: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tabs a {
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] {
  color: var(--text);
  font-weight: 650;
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.18);
}
.tab-rows { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 16px 0; }

/* Stat tiles. Values use proportional figures: tabular ones look loose at
   this size, and nothing here lines up in a column. */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-width: 0;
}
.kpi dt { color: var(--muted); font-size: 13px; }
/* Exact counts, never broken across lines: the tile is sized so a
   ten-digit count fits. */
.kpi dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
  white-space: nowrap;
}
.kpi .note { display: block; color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0; white-space: normal; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}
.card-title { font-size: 15px; margin: 0 0 8px; }
.card > .hint-text { margin: -4px 0 8px; }

/* Charts and bar lists sit two or three across on a wide page and one
   across on a phone. */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 16px;
  margin: 16px 0;
}
.chart-grid.lists { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }

figure.chart {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 10px;
  min-width: 0;
}
.chart-title { font-weight: 650; font-size: 15px; margin: 0 0 8px; }

.daychart { display: block; width: 100%; height: auto; overflow: visible; }
.daychart:focus { outline: none; }
.daychart:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.daychart text {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.daychart .grid line {
  stroke: var(--line);
  stroke-width: 1;
  shape-rendering: crispEdges;
  vector-effect: non-scaling-stroke;
}
.daychart .bars rect { fill: var(--chart-bar); }
.daychart .bars rect.active { fill: var(--chart-bar-active); }

/* Axis labels are in viewBox units, so on a phone they shrink with the chart;
   a larger unit size there keeps them legible. charts.go spaces the dates at
   least 72 units apart, which is what bounds this: at 13 units even the
   right-aligned last date clears its neighbour. */
@media (max-width: 560px) {
  .daychart text { font-size: 13px; }
}

.chart-data { margin-top: 6px; font-size: 13px; }
.chart-data summary { color: var(--muted); cursor: pointer; width: fit-content; }
.chart-data summary:hover { color: var(--text); }
.chart-data .grid { font-size: 13px; margin-top: 6px; }
.chart-data .grid td, .chart-data .grid th { padding: 4px 8px; }
.chart-data tfoot th, .chart-data tfoot td { font-weight: 650; border-bottom: none; }

/* Bar lists: a table whose last column is a bar on a faint track. The number
   columns shrink to their content and the label takes what is left, breaking
   only a name too long to fit on a line of its own. */
.barlist {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.barlist th, .barlist td {
  padding: 5px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  vertical-align: middle;
}
.barlist tbody tr:last-child > * { border-bottom: none; }
.barlist .label {
  text-align: left;
  font-weight: 400;
  overflow-wrap: anywhere;
  padding-right: 10px;
}
.barlist .num {
  width: 1%;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-right: 10px;
}
.barlist .share { color: var(--muted); }
.barlist .bar { width: 28%; min-width: 48px; }
.barlist svg { display: block; width: 100%; height: 8px; border-radius: 2px; }
.barlist .track { fill: var(--chart-track); }
.barlist .fill { fill: var(--chart-bar); }

/* The floating label charts.js moves around. */
.tooltip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 8px));
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12.5px;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.tooltip[hidden] { display: none; }
.tooltip strong { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.tooltip span { color: var(--muted); }

/* A short line of facts about an account or a group under a heading. */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 14px;
}
.facts strong { color: var(--text); font-weight: 600; }

.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 16px 0;
}
.notice p { margin: 0; }
.notice p + p { margin-top: 6px; }

.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin: 20px 0;
  text-align: center;
}
.empty-state h2 { margin: 0 0 6px; }
.empty-state p { margin: 0 0 12px; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
.row.spaced { margin-top: 12px; }

/* --- account profile ------------------------------------------------------ */

.profile-form { max-width: 420px; }
.profile-form .button { align-self: flex-start; }
.profile-links { margin-top: 8px; }

/* --- groups --------------------------------------------------------------- */

.group-name { font-size: 18px; font-weight: 650; margin: 0 0 6px; }
.card .grid { font-size: 14px; }
.card .grid th, .card .grid td { padding: 7px 8px; }
.card .hint-text { margin-top: 8px; }
.card .stack .button { align-self: flex-start; }

.danger-zone {
  margin-top: 36px;
  border: 1px solid color-mix(in srgb, var(--danger) 55%, var(--line));
  border-radius: var(--radius);
  padding: 4px 16px 16px;
}
.danger-zone h2 { margin-top: 12px; }
.danger-zone p { color: var(--muted); margin: 0 0 8px; }
.danger-zone .stack .button { align-self: flex-start; margin-top: 10px; }

/* --- map ------------------------------------------------------------------ */

body.map-page {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#map { position: absolute; inset: 0; }

.hint {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
  z-index: 1;
  pointer-events: none;
  white-space: nowrap;
}

/* Shown over the map to anyone who is not signed in, and raised again when a
   session expires while the page is open. */
.signin-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: min(360px, calc(100% - 32px));
  text-align: center;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.signin-card[hidden] { display: none; }
.signin-card h2 { margin: 0 0 6px; font-size: 17px; }
.signin-card p { margin: 0; color: var(--muted); font-size: 14px; }
.signin-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px !important;
}

.legend {
  position: absolute;
  left: 10px;
  bottom: 28px;
  margin: 0;
  padding: 8px 10px;
  list-style: none;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
  z-index: 1;
}
.legend .dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: baseline;
}
.dot.open { background: #3fbf7f; }
.dot.wep { background: #e05252; }
.dot.wpa { background: #e0a23c; }
.dot.other { background: #8a93a3; }
.legend[hidden] { display: none; }

/* The coverage legend: the fixed count steps of the hexagon fill. Each
   swatch is drawn the way the map draws a hexagon, the theme's
   COVERAGE_FILL colour at COVERAGE_OPACITY over the theme's basemap
   background, so it looks like the hexagons it names: dim to bright over the
   dark basemap (a near-black of about #0c0c0c), light to dark over the light
   one (#f8f4f0, the liberty style's). The outline gives every step an edge
   against the legend panel, which the faintest steps would otherwise lack. */
.legend.coverage {
  display: grid;
  grid-template-columns: repeat(5, auto);
  gap: 4px 10px;
  align-items: center;
}
.legend.coverage[hidden] { display: none; }
.legend .legend-title { grid-column: 1 / -1; color: var(--text); font-weight: 600; }
.legend .swatch {
  --basemap: #0c0c0c;
  --coverage-opacity: 85%;
  --tint: color-mix(in srgb, var(--swatch) var(--coverage-opacity), transparent);
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -2px;
  background: linear-gradient(var(--tint), var(--tint)), var(--basemap);
  box-shadow: 0 0 0 1px var(--muted);
}
.swatch.c1 { --swatch: #1a3a66; }
.swatch.c2 { --swatch: #245fa6; }
.swatch.c3 { --swatch: #3a86dc; }
.swatch.c4 { --swatch: #72b0f2; }
.swatch.c5 { --swatch: #bddcfc; }
:root[data-theme="light"] .legend .swatch { --basemap: #f8f4f0; }
:root[data-theme="light"] .swatch.c1 { --swatch: #9cc3f2; }
:root[data-theme="light"] .swatch.c2 { --swatch: #5e9ce6; }
:root[data-theme="light"] .swatch.c3 { --swatch: #2a73cf; }
:root[data-theme="light"] .swatch.c4 { --swatch: #17509a; }
:root[data-theme="light"] .swatch.c5 { --swatch: #0a2d5e; }

@media (max-width: 480px) {
  .legend { gap: 8px; bottom: 24px; font-size: 11px; }
}

/* MapLibre's controls ship white, for a light basemap. They take the page
   palette instead, in both themes, and their dark glyphs are inverted on the
   dark one. maplibre-gl.css loads after this file, so every rule here is
   anchored on .map-shell to outrank its own. */
.map-shell .maplibregl-ctrl-group {
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line);
}
.map-shell .maplibregl-ctrl-group button + button { border-top-color: var(--line); }
.map-shell .maplibregl-ctrl-group button:not(:disabled):hover {
  background-color: color-mix(in srgb, var(--text) 10%, transparent);
}
:root:not([data-theme="light"]) .map-shell .maplibregl-ctrl-icon,
:root:not([data-theme="light"]) .map-shell .maplibregl-ctrl-attrib-button {
  filter: invert(1);
}
.map-shell .maplibregl-ctrl.maplibregl-ctrl-attrib,
.map-shell .maplibregl-ctrl-attrib.maplibregl-compact {
  background-color: color-mix(in srgb, var(--panel) 80%, transparent);
  color: var(--muted);
}
.map-shell .maplibregl-ctrl-attrib a { color: var(--muted); }
.map-shell .maplibregl-ctrl-scale {
  background-color: color-mix(in srgb, var(--panel) 75%, transparent);
  border-color: var(--muted);
  color: var(--text);
}

/* MapLibre popups inherit the page palette. */
.maplibregl-popup-content {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.maplibregl-popup-tip { display: none; }

.popup h3 { margin: 0 0 6px; font-size: 14px; word-break: break-word; }
.popup h3.hidden-ssid { color: var(--muted); font-style: italic; }
.popup dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  font-size: 12.5px;
}
.popup dt { color: var(--muted); }
.popup dd { margin: 0; word-break: break-word; }

/* --- toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  z-index: 10;
  max-width: calc(100vw - 32px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.toast[hidden] { display: none; }
