:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --border: #dde1e6;
  --accent: #2a7fd4;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --busy: #b7791f;
  --error: #c53030;
  --error-bg: #fdf0f0;
  --info-bg: #eef5fc;
  --code-bg: #eef0f3;
  --radius: 10px;
  --waves: rgb(95 107 122 / 0.3);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --text: #e6e9ed;
    --muted: #97a1ad;
    --border: #2d333b;
    --accent: #4c9be8;
    --accent-text: #0d1117;
    --ok: #3fb96f;
    --busy: #e0a53a;
    --error: #f07171;
    --error-bg: #2a1a1c;
    --info-bg: #16222f;
    --code-bg: #252b33;
    --waves: rgb(151 161 173 / 0.17);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

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

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

code {
  font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
}

p {
  margin: 0 0 0.5rem;
}

.muted,
.help {
  color: var(--muted);
}

.help {
  font-size: 0.875rem;
  margin: 0.35rem 0 0;
}

/* Read out, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Layout */

/* The waves behind every page (waves.js). */
.waves {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  color: var(--waves);
  pointer-events: none;
}

.top {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 16px;
}

.brand {
  font-weight: 650;
  letter-spacing: 0.01em;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 3rem;
}

.with-sidebar {
  --sidebar-width: 14rem;
  /* Keeps the icons where they are in the full sidebar, centered. */
  --rail-width: 3.875rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 100vh;
}

.with-sidebar main {
  width: 100%;
  padding-top: 1.5rem;
}

/* Icons from static/icons.svg. */
.icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
  color: var(--text);
  background: var(--bg);
}

.icon-button .icon {
  transition: transform 0.2s ease;
}

.icon-button:hover .icon {
  transform: scale(1.12);
}

/* An icon button's name: read out, not shown. */
.icon-button .label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  overflow: hidden auto;
  padding: 1rem 0.625rem 1.25rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width 0.25s ease;
}

.sidebar .label {
  transition: opacity 0.2s ease;
}

.sidebar :is(a, button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.sidebar-head {
  display: flex;
  align-items: center;
}

.sidebar-head .brand {
  padding-left: 0.75rem;
  white-space: nowrap;
}

.sidebar-head .icon-button {
  margin-left: auto;
}

.mobile-bar,
.sidebar-backdrop,
.sidebar-close,
.when-collapsed {
  display: none;
}

.menu ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu a,
.group-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.menu .label {
  flex: none;
}

/* The bar on a link's left edge: half drawn on hover, whole on the page you're on. */
.menu a::before,
.group-toggle::before {
  content: "";
  position: absolute;
  top: 0.4rem;
  bottom: 0.4rem;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.menu a:hover,
.group-toggle:hover {
  color: var(--text);
  background: var(--bg);
}

.menu a:hover::before {
  transform: scaleY(0.5);
}

.menu .icon {
  transition: transform 0.2s ease, color 0.15s ease;
}

.menu a:hover .icon,
.group-toggle:hover .icon:first-child {
  color: var(--accent);
  transform: scale(1.12);
}

.menu a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  background: var(--info-bg);
}

.menu a[aria-current="page"] .icon {
  color: var(--accent);
}

/* A folded group shows the bar when the page you're on is in it. */
.menu a[aria-current="page"]::before,
.group:has([aria-current="page"]) > .group-toggle[aria-expanded="false"]::before {
  transform: scaleY(1);
}

.group-toggle {
  color: var(--text);
  font-weight: 600;
}

.group-toggle .chevron {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: var(--muted);
}

.group-toggle[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

/* Folding animates the rows from 1fr to 0fr; the links are hidden once they're out of sight. */
.group-items {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.25s ease;
}

.group-items > ul {
  min-height: 0;
  overflow: hidden;
  margin-left: calc(0.75rem + 8.5px);
  padding-left: 0.4rem;
  border-left: 1px solid var(--border);
  transition: visibility 0.25s;
}

.group-items > ul > li:first-child {
  margin-top: 2px;
}

.group-toggle[aria-expanded="false"] + .group-items {
  grid-template-rows: 0fr;
}

.group-toggle[aria-expanded="false"] + .group-items > ul {
  visibility: hidden;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.account-name {
  min-width: 0;
  padding-left: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout {
  flex: none;
  margin-left: auto;
}

.logout .label {
  position: static;
  width: auto;
  height: auto;
  clip-path: none;
}

.logout:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* Folded, the sidebar is a rail of icons, and the labels turn into tooltips. */
@media (min-width: 721px) {
  .sidebar-collapsed .sidebar {
    width: var(--rail-width);
    overflow: visible;
  }

  .sidebar-collapsed .sidebar-head .brand,
  .sidebar-collapsed .account-name,
  .sidebar-collapsed .group-toggle,
  .sidebar-collapsed .when-expanded {
    display: none;
  }

  .sidebar-collapsed .when-collapsed {
    display: block;
  }

  /* Groups can't fold on the rail; lines set them apart instead. */
  .sidebar-collapsed .group {
    padding: 4px 0;
    border-block: 1px solid var(--border);
  }

  .sidebar-collapsed .group-toggle + .group-items {
    grid-template-rows: 1fr;
  }

  .sidebar-collapsed .group-toggle + .group-items > ul {
    visibility: visible;
    overflow: visible;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .sidebar-collapsed .group-items > ul > li:first-child {
    margin-top: 0;
  }

  .sidebar-collapsed .sidebar .label {
    position: absolute;
    top: 50%;
    left: calc(100% + 1.125rem);
    z-index: 1;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    background: var(--text);
    color: var(--bg);
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
    opacity: 0;
    pointer-events: none;
    transform: translate(-4px, -50%);
    transition: none;
  }

  .sidebar-collapsed .sidebar :is(a, button):is(:hover, :focus-visible) .label {
    opacity: 1;
    transform: translate(0, -50%);
    transition: opacity 0.15s ease 0.1s, transform 0.15s ease 0.1s;
  }
}

/* On narrow screens the sidebar is a drawer, opened from a bar at the top. */
@media (max-width: 720px) {
  .with-sidebar {
    display: block;
  }

  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 16px 0.5rem 4px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(17rem, 85vw);
    height: auto;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0.25s;
  }

  .sidebar-open .sidebar {
    transform: none;
    visibility: visible;
    box-shadow: 0 0 32px rgb(0 0 0 / 0.25);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    background: rgb(0 0 0 / 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s;
  }

  .sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .sidebar-open {
    overflow: hidden;
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar-close {
    display: inline-flex;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar *,
  .sidebar *::before,
  .sidebar-backdrop,
  .mobile-bar * {
    transition: none !important;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-head {
  margin-bottom: 1.25rem;
}

.login {
  max-width: 420px;
  margin: 12vh auto 0;
}

/* Status */

.status {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.status .dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 0.45rem;
  border-radius: 50%;
  background: var(--muted);
}

.tone-ok .dot { background: var(--ok); }
.tone-busy .dot { background: var(--busy); }
.tone-error .dot { background: var(--error); }

.status .headline {
  font-weight: 600;
  margin: 0;
}

.status .detail {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Alerts */

.alert {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.alert.info {
  background: var(--info-bg);
}

.alert.error {
  background: var(--error-bg);
  color: var(--error);
}

.alert ul {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

/* Forms */

.field {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.field label,
.field .label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.required {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.read-only {
  margin: 0;
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--error);
}

.error-text {
  color: var(--error);
  font-size: 0.875rem;
  margin: 0.35rem 0 0;
}

.actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.import .actions {
  border-top: 0;
}

.import summary,
.collapsible summary,
.add-record summary {
  cursor: pointer;
  font-weight: 600;
}

.import form {
  margin-top: 1rem;
}

.collapsible > p {
  margin-top: 0.75rem;
}

.import textarea {
  margin-top: 0.75rem;
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

button.danger {
  color: var(--error);
  border-color: var(--error);
}

button.link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font-weight: 500;
}

.login button.primary {
  width: 100%;
  padding: 0.7rem 1rem;
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.field label.check {
  font-weight: 600;
  margin: 0;
}

/* A value shown as text and changed in place, like a node's display name: hovering shows a
   pencil, and while it's being changed Save, Cancel and its help show. */
.inline-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  /* Hovering the value, not the whole line, shows the pencil. */
  width: fit-content;
  max-width: 100%;
  margin: 0 0 0.5rem;
}

.inline-edit > input {
  width: auto;
  field-sizing: content;
  min-width: 12ch;
  max-width: 100%;
  /* The text lines up with the heading above. */
  margin-left: calc(-0.5rem - 1px);
  padding: 0.1rem 0.5rem;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.inline-edit > input::placeholder {
  color: var(--muted);
  font-style: italic;
  opacity: 0.8;
}

.inline-edit:hover > input {
  border-color: var(--border);
}

.inline-edit > input:focus,
.inline-edit.changed > input,
.inline-edit.invalid > input {
  border-color: var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: text;
}

.inline-edit.invalid > input[aria-invalid] {
  border-color: var(--error);
}

.inline-edit-hint {
  display: inline-flex;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.inline-edit-hint .icon {
  width: 16px;
  height: 16px;
}

.inline-edit:hover .inline-edit-hint {
  opacity: 1;
}

.inline-edit button {
  padding: 0.2rem 0.75rem;
  font-size: 0.875rem;
}

.inline-edit button,
.inline-edit .help {
  display: none;
}

.inline-edit .help,
.inline-edit .error-text {
  flex-basis: 100%;
  margin: 0;
}

.inline-edit:not(.invalid) .error-text {
  display: none;
}

.inline-edit:is(:focus-within, .changed, .invalid) :is(button, .help) {
  display: block;
}

.inline-edit:is(:focus-within, .changed, .invalid) .inline-edit-hint {
  display: none;
}

/* Without hover, the pencil always shows that it can be changed. */
@media (hover: none) {
  .inline-edit-hint {
    opacity: 1;
  }
}

/* DNS */

.crumbs {
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.badge {
  font-size: 0.75rem;
  color: var(--busy);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 0.45rem;
  margin-left: 0.4rem;
}

.zones,
.records {
  list-style: none;
  margin: 0;
  padding: 0;
}

.zones li {
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.zones a {
  font-weight: 600;
}

.records li {
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.records .type {
  font: 600 0.8rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  text-align: center;
}

.records p {
  margin: 0;
}

.record-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.record-content {
  font: 0.875rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.record-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.add-record {
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.add-record summary {
  color: var(--accent);
}

.record-form {
  margin-top: 0.75rem;
}

.record-form .actions {
  padding-bottom: 0.25rem;
}

.record-form .row {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  gap: 0 1rem;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.danger-zone p {
  margin: 0;
}

.danger-zone label.check {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.actions.plain {
  border-top: 0;
  padding-top: 0.5rem;
}

@media (max-width: 480px) {
  .record-form .row {
    grid-template-columns: minmax(0, 1fr);
  }

  .records li {
    grid-template-columns: 3.75rem minmax(0, 1fr);
  }

  .records .record-link {
    grid-column: 2;
  }
}

/* Nodes and VPN */

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 1rem;
}

.field-help {
  margin: -0.5rem 0 1rem;
}

.badge.plain {
  color: var(--muted);
}

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

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.list p {
  margin: 0;
}

.item-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.item-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: none;
}

button.danger-link {
  color: var(--error);
}

/* A button in a line of text, such as the Users page's Reset beside a member's traffic. */
form.inline-action {
  display: inline;
  margin-left: 0.5rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.pill.tone-ok::before { background: var(--ok); }
.pill.tone-busy::before { background: var(--busy); }
.pill.tone-error::before { background: var(--error); }

.facts {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 0.6rem 1rem;
  margin: 0;
}

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

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.facts summary {
  cursor: pointer;
  color: var(--accent);
}

.facts details p {
  margin: 0.35rem 0 0;
}

pre.log,
pre.key {
  font: 0.8rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--code-bg);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin: 0.75rem 0 0;
}

pre.log {
  max-height: 30rem;
  overflow: auto;
}

.log strong {
  color: var(--accent);
}

.log .log-error {
  color: var(--error);
  font-weight: 600;
}

.add-device .field {
  border-top: 0;
  padding-bottom: 0;
}

.input-with-button {
  display: flex;
  gap: 0.5rem;
}

.input-with-button button {
  flex: none;
}

@media (max-width: 480px) {
  .form-row,
  .facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .facts dd {
    margin-bottom: 0.4rem;
  }
}

/* Overview: the globe (static/globe.js), on the page's background, beside the nodes and their load
   (static/load.js) in their card */

main.wide {
  max-width: 1280px;
}

.overview {
  container: overview / inline-size;
}

.overview-body {
  display: grid;
  gap: 1rem 1.75rem;
  align-items: start;
}

/* Over the list, square. */
.globe {
  position: relative;
  width: min(100%, 26rem);
  aspect-ratio: 1;
}

/* Out of the flow, so the canvas's drawing buffer, which globe.js sizes to the box, can't size the
   box in turn. */
.globe canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  opacity: 0;
  /* Vertical swipes still scroll the page on phones; the rest turns the globe. */
  touch-action: pan-y;
  /* Zoomed in, the globe fades out round its edge, with no box around it to cut it off. */
  mask-image: radial-gradient(closest-side, #000 92%, transparent);
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.4s ease;
}

.globe.ready canvas {
  opacity: 1;
}

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

.globe canvas.pointing {
  cursor: pointer;
}

.globe.dragging canvas {
  cursor: grabbing;
}

/* A marker's details. It follows the marker, so it's moved with a transform. */
.globe-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 10rem;
  max-width: min(18rem, calc(100% - 16px));
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.14);
  font-size: 0.875rem;
  /* Shown on hover, it mustn't take the pointer from the marker; clicked, its links work. */
  pointer-events: none;
}

.globe-tip.pinned {
  pointer-events: auto;
}

.globe-tip[hidden] {
  display: none;
}

.globe-tip p {
  margin: 0;
}

.globe-tip .pill {
  margin-top: 0.3rem;
  font-size: 0.8rem;
}

/* With room, the globe takes the top left corner and the nodes' card the top right, two parts to
   three. The globe gives way first: the list keeps the width that shows the load in columns (see
   below), plus the card's padding and border. */
@container overview (width >= 52rem) {
  .overview-body {
    grid-template-columns: minmax(13rem, 2fr) minmax(calc(37rem + 2px), 3fr);
  }

  /* It stays in view beside a long list. */
  .overview-globe {
    position: sticky;
    top: 1.5rem;
  }

  .globe {
    width: 100%;
  }
}

.overview-nodes {
  container: nodes / inline-size;
  margin-bottom: 0;
}

.overview-nodes > .muted {
  margin: 0;
}

.globe-nodes .item-actions {
  gap: 0.5rem;
}

.globe-nodes .icon-button {
  padding: 0.35rem;
}

/* Where a node with no place has no button, so the states stay in line. */
.show-spacer {
  width: calc(18px + 0.7rem);
}

.globe-nodes > .load-head {
  display: none;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  font-size: 0.875rem;
  /* Digits of one width, so the numbers don't jitter as they change. */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metric-name {
  color: var(--muted);
  font-size: 0.75rem;
}

.rate {
  display: flex;
  gap: 0.35rem;
}

.rate .arrow {
  color: var(--muted);
}

.meter {
  height: 4px;
  margin-top: 0.1rem;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}

.meter > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s ease, background-color 0.4s ease;
}

.metric[data-level="high"] .meter > span {
  background: var(--busy);
}

.metric[data-level="full"] .meter > span {
  background: var(--error);
}

/* No load to show, each column has just a dash. Hidden, not gone, so rows keep their height. */
.load[data-unknown] :is(.meter, .arrow, .rate + .rate) {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .meter > span {
    transition: none;
  }
}

/* Narrow, a node's load is a row of its own, under its name. */
@container nodes (width < 34rem) {
  .globe-nodes > li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "about actions"
      "load load";
    gap: 0.6rem 1rem;
    align-items: baseline;
  }

  .node-about {
    grid-area: about;
  }

  .globe-nodes .item-actions {
    grid-area: actions;
  }

  .load {
    grid-area: load;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }
}

/* Wide, the list is a table: the load is in columns to the right of the names, under a heading
   row. The rows share the list's columns (subgrid), so each column is as wide as its widest cell. */
@container nodes (width >= 34rem) {
  .globe-nodes {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(3, auto) auto;
    column-gap: 1rem;
  }

  .globe-nodes > li {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    column-gap: 1rem;
    /* The numbers on the line of the node's name. */
    align-items: baseline;
  }

  .globe-nodes > .load-head {
    display: grid;
    padding: 0 0 0.5rem;
    border-top: 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
  }

  .load-head > :not(:first-child) {
    text-align: right;
  }

  .load {
    display: contents;
  }

  /* Wide enough for any value, so the columns keep their width as the numbers change. */
  .metric {
    min-width: 3rem;
    text-align: right;
  }

  .metric[data-metric="net"] {
    min-width: 5.5rem;
  }

  .rate {
    justify-content: flex-end;
  }

  /* The heading row names the columns; screen readers still read each cell's name. */
  .metric-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* The load over time (static/graphs.js), under the globe and the list. A node's color is its
   place in the list: eight colors that stay apart for color-blind eyes too, in this order, stepped
   for each theme. Past the eighth, nodes are grey. */

.graphs-card {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-other: #8a929c;
  --graph-grid: #eceef1;
  --graph-base: #c9ced5;
  margin: 1.5rem 0 0;
}

@media (prefers-color-scheme: dark) {
  .graphs-card {
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --series-other: #6b7480;
    --graph-grid: #262b32;
    --graph-base: #3a414b;
  }
}

.graphs-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}

.graphs-head p {
  margin: 0;
  font-size: 0.875rem;
}

/* How far back: buttons joined in a row, the one chosen filled. */
.range {
  display: inline-flex;
  flex: none;
}

.range button {
  padding: 0.3rem 0.8rem;
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.range button + button {
  margin-left: -1px;
}

.range button:first-child {
  border-radius: 6px 0 0 6px;
}

.range button:last-child {
  border-radius: 0 6px 6px 0;
}

.range button[aria-pressed="true"] {
  position: relative;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.range button:focus-visible {
  position: relative;
  z-index: 1;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.graph-legend li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: default;
  transition: opacity 0.15s ease;
}

.graph-legend li.dim {
  opacity: 0.4;
}

/* A short stroke of the node's color, as its line is drawn. */
.graph-key {
  flex: none;
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.graphs-empty {
  margin: 0 0 1rem;
}

.graphs {
  display: grid;
  gap: 1.25rem 2rem;
  transition: opacity 0.2s ease;
}

/* Asking again, the graphs stay as they were, faded, until the answer. */
.graphs-card[aria-busy] .graphs {
  opacity: 0.65;
}

@container overview (width >= 44rem) {
  .graphs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.graph {
  margin: 0;
  min-width: 0;
}

.graph figcaption {
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.graph-plot {
  position: relative;
}

.graph svg {
  display: block;
  width: 100%;
  overflow: visible;
  touch-action: pan-y;
}

.graph svg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.graph-grid line {
  stroke: var(--graph-grid);
  stroke-width: 1;
}

.graph-grid line.graph-base {
  stroke: var(--graph-base);
}

.graph-grid text {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.graph-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  transition: opacity 0.15s ease;
}

.graph-line circle {
  stroke: none;
}

.graph-line.dim {
  opacity: 0.15;
}

.graph-cross {
  stroke: var(--muted);
  stroke-width: 1;
  pointer-events: none;
}

/* The values at the crosshair's time. It follows the crosshair, so it's moved with a transform. */
.graph-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: grid;
  gap: 0.2rem;
  min-width: 8rem;
  padding: 0.45rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.14);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.graph-tip[hidden] {
  display: none;
}

.graph-tip p {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.graph-tip .graph-tip-time {
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .graphs,
  .graph-line,
  .graph-legend li {
    transition: none;
  }
}

/* Protocols: the Reality sites the nodes' inbounds borrow, the limits on what's handed on to them,
   and the certificates scans trust */

.reality .card-head p,
.node-sites-card .card-head p,
.reality form {
  max-width: 48rem;
}

.reality .field .help {
  overflow-wrap: anywhere;
}

.node-reality {
  align-items: baseline;
  margin: 0.15rem 0 0;
}

/* Lined up with the meta line above, not with the heading as elsewhere. */
.node-reality > input {
  margin-left: 0;
  font-size: 0.875rem;
}

.node-reality:is(:focus-within, .changed, .invalid) .node-sni {
  display: none;
}

/* Its SNIs, typed in, on a line of their own while it's being changed. */
.node-reality .sni-typed {
  display: none;
  flex-basis: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

.node-reality:is(:focus-within, .changed, .invalid) .sni-typed {
  display: flex;
}

.node-reality .sni-typed label.check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.node-reality input.sni-names {
  flex: 1 1 14rem;
  max-width: 28rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.875rem;
}

.node-reality input.sni-names[aria-invalid] {
  border-color: var(--error);
}

/* Typed SNIs show while they're ticked. */
.sni-typed:not(:has(input[name$="sni_typed"]:checked)) .sni-names {
  display: none;
}

/* What a node's local target is doing, after its SNI. */
.node-sni .tone-ok {
  color: var(--ok);
}

.node-sni .tone-busy {
  color: var(--busy);
}

.node-sni .tone-error {
  color: var(--error);
}

/* Why a node waits for its local target, or why its target makes it a relay. */
.node-note {
  max-width: 48rem;
  margin: 0.15rem 0 0.25rem;
}

.warning-text {
  margin: 0.35rem 0 0;
  padding-left: 0.6rem;
  border-left: 3px solid var(--busy);
  font-size: 0.875rem;
}

.reality .fallback {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.reality .fallback h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.reality .fallback fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.reality .fallback legend {
  padding: 0.7rem 1rem 0;
  font-weight: 600;
}

@media (max-width: 480px) {
  .reality .fallback fieldset {
    grid-template-columns: minmax(0, 1fr);
  }
}

.reality .sni-typed > label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  margin: -0.5rem 0 1rem;
  font-size: 0.875rem;
}

.reality .sni-typed > .sni-names {
  margin-top: -0.5rem;
  padding-top: 0;
  border-top: 0;
}

.certificates .card-head p,
.certificates form {
  max-width: 48rem;
}

.certificates .card-head code {
  overflow-wrap: anywhere;
}

.certificates .list {
  margin-bottom: 1rem;
}

.fingerprint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.node-site {
  flex: 1;
  min-width: 0;
}

/* Narrow, a node's text takes the row, with its Reality target, and its state and button go under
   it. */
@media (max-width: 480px) {
  .node-sites > li {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .node-sites .node-site {
    flex-basis: 100%;
  }
}

.icon-button.danger-icon:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* The page the bot's button opens (import.html): a link that opens YPtun, styled as a button, and
   the subscription's address with a button under it that copies it (static/copy.js). */
.yptun-import {
  max-width: 420px;
  margin: 8vh auto 0;
}

a.button {
  display: inline-block;
  font-weight: 600;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  text-decoration: none;
}

a.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.copy {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.copy pre.key {
  margin: 0;
}

.copy button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.copy button .when-copied,
.copy button.copied .when-idle {
  display: none;
}

.copy button.copied .when-copied {
  display: inline;
}
