/* Status changes pop at once; only recovery sparks celebrate a transition.
   Colour means status, using theme tokens and derived tints, never gradients.
   Motion is the same for everyone and marks updates, entrances and interaction. */

/* Tokens ------------------------------------------------------------------ */

:root {
  --line: color-mix(in srgb, var(--text) 14%, var(--page));
  --line-strong: color-mix(in srgb, var(--text) 28%, var(--page));
  --surface: color-mix(in srgb, var(--text) 3%, var(--page));
  --card: light-dark(var(--page), color-mix(in srgb, var(--text) 5%, var(--page)));
  --up-bg: color-mix(in srgb, var(--up) 13%, var(--page));
  --down-bg: color-mix(in srgb, var(--down) 13%, var(--page));
  --amber-bg: color-mix(in srgb, var(--amber) 15%, var(--page));
  --unknown-bg: color-mix(in srgb, var(--unknown) 15%, var(--page));
  --accent-bg: color-mix(in srgb, var(--accent) 12%, var(--page));
  --tone: var(--muted);
  --tone-bg: var(--surface);
  --shadow-card: 0 1px 2px light-dark(#0000000d, #00000059),
    0 6px 16px light-dark(#0000000a, #00000033);
  --shadow-pop: 0 18px 50px light-dark(#00000026, #00000080);
  --shadow-dialog: 0 24px 80px light-dark(#00000030, #00000070);
  --shadow-toast: 0 8px 28px #00000020;
  --scrim: light-dark(#000000a6, #000000bf);
  --radius: 12px;
  --radius-sm: 8px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 150ms;
  --t-med: 300ms;
  --t-slow: 600ms;
  --fs-hero: clamp(1.625rem, 1.1rem + 2.4vw, 2.375rem);
  --fs-h2: 1rem;
  --fs-meta: 0.8125rem;
  --fs-xs: 0.75rem;
}

[data-status="UP"] {
  --tone: var(--up);
  --tone-bg: var(--up-bg);
}

[data-status="DOWN"] {
  --tone: var(--down);
  --tone-bg: var(--down-bg);
}

[data-status="UNKNOWN"] {
  --tone: var(--unknown);
  --tone-bg: var(--unknown-bg);
}

[data-status="NODATA"] {
  --tone: var(--muted);
  --tone-bg: var(--surface);
}

[data-status="PARTIAL"] {
  --tone: var(--amber);
  --tone-bg: var(--amber-bg);
}

/* Base -------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
  transition: background-color var(--t-med) ease, color var(--t-med) ease;
}

::selection {
  background: var(--selection);
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 0 0 0.75rem;
  font-weight: 650;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: var(--fs-h2);
}

h3,
h4 {
  font-size: 1rem;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  min-width: 0;
}

.num,
time,
.counter,
.pill,
.badge {
  font-variant-numeric: tabular-nums;
}

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

.meta,
.hint {
  color: var(--muted);
  font-size: var(--fs-meta);
}

.hint {
  font-weight: 400;
}

.note {
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.mono,
pre,
code,
#invite-link {
  font-family: var(--mono);
}

.mono,
#invite-link {
  font-size: 0.875rem;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Layout ------------------------------------------------------------------ */

.wrap {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1rem;
}

main {
  flex: 1;
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

main.wrap {
  padding-top: 1.5rem;
  padding-bottom: 4rem;
}

[id^="group-"],
#recently-removed {
  scroll-margin-top: 1rem;
}

.site-header {
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.site-title {
  display: inline-block;
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

a.site-title:hover {
  text-decoration: underline;
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.75rem;
  min-width: 0;
  max-width: 100%;
}

.site-header .brand > .site-nav,
.site-header .brand > .live {
  flex: none;
}

.site-header .brand .live {
  margin-left: 0;
  white-space: nowrap;
}

.site-header .brand .live-text {
  display: none;
}

.site-header .wrap > .site-nav {
  flex: 1 1 auto;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  font-size: 0.9375rem;
}

.site-nav a,
.site-nav .nav-signout {
  color: var(--muted);
  text-decoration: none;
  padding: 0.25rem 0;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}

.site-nav a:hover,
.site-nav .nav-signout:hover {
  color: var(--text);
  opacity: 1;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

#logout-form {
  display: flex;
  margin-left: auto;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-meta);
}

.site-footer .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.875rem;
  padding-bottom: 0.875rem;
}

.site-footer .version {
  justify-self: start;
  overflow-wrap: anywhere;
}

.zone-note {
  text-align: center;
  overflow-wrap: anywhere;
}

.site-footer .theme-mode {
  justify-self: end;
}

/* Components -------------------------------------------------------------- */

/* Buttons and forms. Unclassed form buttons share the primary button style. */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--page);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out), opacity var(--t-fast),
    background-color var(--t-fast);
}

button:hover,
.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.97);
}

button:disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

button.secondary,
.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

button.ghost,
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

button.ghost:hover,
.btn.ghost:hover {
  color: var(--text);
  background: var(--surface);
}

.btn.big {
  width: 100%;
  padding: 0.75rem 1.125rem;
  font-size: 1.0625rem;
}

form.inline {
  display: inline;
  margin-top: 0;
  margin-bottom: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.inline-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

input,
select,
textarea {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--page);
  color: var(--text);
}

input,
textarea {
  width: 100%;
}

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

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

.inline-fields input {
  width: auto;
  max-width: 100%;
}

textarea {
  resize: vertical;
}

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--down);
  background: var(--down-bg);
  color: var(--down);
  box-shadow: 0 0 0 1px var(--down);
}

.form-error {
  color: var(--down);
  background: var(--down-bg);
  border: 1px solid var(--down);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.form-error:empty {
  display: none;
}

.notice {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.875rem 1rem;
  margin-bottom: 1.5rem;
  overflow-wrap: anywhere;
}

.notice h2 {
  margin-bottom: 0.5rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
  margin-top: 2rem;
}

.panel.narrow {
  max-width: 26rem;
  margin-left: auto;
  margin-right: auto;
}

.panel h1,
.panel h2 {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: var(--fs-meta);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.field input {
  width: 100%;
}

/* Status components. No component transitions its status colour. */
.pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--tone);
  background: var(--tone-bg);
}

.pill.partial {
  --tone: var(--amber);
  --tone-bg: var(--amber-bg);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 0.875rem 1rem;
  transition: transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast);
}

.band {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  margin: -0.875rem -1rem 0.75rem;
  padding: 0.3125rem 1rem;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  background: color-mix(in srgb, var(--tone) 25%, var(--page));
  color: var(--tone);
  text-align: center;
  font-size: var(--fs-meta);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

a.card,
button.card {
  color: inherit;
  text-decoration: none;
}

a.card:hover,
button.card:hover {
  transform: translateY(-2px);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  max-width: 100%;
  padding: 0.3125rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out),
    border-color var(--t-fast);
}

.chip:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  opacity: 1;
}

.chip::before {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--tone);
}

.chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banner {
  --tone: var(--accent);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 0.875rem 1rem;
}

.banner[data-severity="info"] {
  --tone: var(--accent);
}

.banner[data-severity="warning"] {
  --tone: var(--amber);
}

.banner[data-severity="error"] {
  --tone: var(--down);
}

.banner-text {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.banner-meta {
  display: block;
  margin-top: 0.375rem;
  font-size: var(--fs-meta);
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 0 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

/* History strips grow in through strips.ts, never through CSS keyframes. */
.strip {
  display: flex;
  gap: 3px;
  min-width: 0;
  height: 1.5rem;
  align-items: stretch;
}

.strip.small {
  height: 1.125rem;
  gap: 2px;
}

.seg {
  flex: 1 1 0;
  min-width: 3px;
  border-radius: 3px;
  background: var(--up);
  transform-origin: bottom;
  cursor: default;
  transition: transform var(--t-fast) var(--ease-out), filter var(--t-fast);
}

.seg[data-band="up"] {
  background: var(--up);
}

.seg[data-band="minor"] {
  background: var(--amber);
}

.seg[data-band="major"] {
  background: var(--down);
}

.seg[data-band="none"] {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--nodata);
}

.seg:hover,
.seg:focus-visible {
  transform: scaleY(1.12);
  filter: brightness(1.08);
  outline: none;
}

/* Shared tooltip, positioned and raised into the top layer by tips.ts. */
#tip {
  position: fixed;
  z-index: 2147483647;
  pointer-events: none;
  max-width: min(16rem, calc(100vw - 1rem));
  width: max-content;
  margin: 0;
  inset: auto;
  border: 0;
  overflow: visible;
  white-space: pre-line;
  overflow-wrap: anywhere;
  padding: 0.4375rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-meta);
  line-height: 1.4;
  background: var(--text);
  color: var(--page);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translateY(4px) scale(0.96);
  transform-origin: bottom center;
  transition: opacity var(--t-fast),
    transform var(--t-fast) var(--ease-out);
}

#tip.is-on {
  opacity: 1;
  transform: none;
}

@starting-style {
  #tip.is-on {
    opacity: 0;
    transform: translateY(4px) scale(0.96);
  }
}

.live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1rem;
}

.live-text {
  font-size: var(--fs-meta);
  white-space: nowrap;
  color: var(--muted);
}

.live[data-live="lost"] .live-text {
  color: var(--amber);
}

.live-dot {
  --beat: var(--up);
  position: relative;
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--up);
  flex: none;
}

.live-dot::before {
  content: "";
  position: absolute;
  inset: -0.5rem;
}

.live[data-live="lost"] .live-dot {
  background: var(--amber);
  animation: none;
}

/* The dot owns the pulse, keeping it concentric at every layout size. */
.live-dot.is-beat {
  animation: beat 1100ms var(--ease-out);
}

@keyframes beat {
  from {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--beat) 55%, transparent);
  }
  to {
    box-shadow: 0 0 0 11px color-mix(in srgb, var(--beat) 0%, transparent);
  }
}

/* Tables, facts and raw errors. */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0 0 0.75rem;
}

.facts > div {
  display: flex;
  gap: 0.375rem;
  font-size: 0.875rem;
  min-width: 0;
}

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

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.watch-status {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.625rem 0.875rem;
  margin-bottom: 1.5rem;
}

.watch-status .facts {
  margin: 0;
}

pre {
  margin: 0.5rem 0;
  padding: 0.625rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: var(--fs-meta);
}

.tbl-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.875rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

td {
  font-variant-numeric: tabular-nums;
}

tr:last-child td {
  border-bottom: 0;
}

/* Dialogs: paste's panel rise, perspective and blurred backdrop. */
dialog {
  width: min(27.5rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--text);
}

.dialog-motion,
#toast-region {
  perspective: 1000px;
}

.dialog-panel,
.toast {
  transform-origin: center bottom;
  transition: transform 250ms ease, opacity 250ms ease;
}

.dialog-panel {
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  box-shadow: var(--shadow-dialog);
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

dialog::backdrop {
  background: var(--scrim);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  opacity: 0;
  transition: opacity 250ms ease;
}

dialog.is-visible::backdrop {
  opacity: 1;
}

dialog.is-leaving::backdrop {
  opacity: 0;
}

body:has(dialog[open]) {
  overflow: hidden;
}

dialog h2 {
  font-size: 1.5rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.625rem;
  margin-top: 0.75rem;
}

dialog:not(.is-visible) .dialog-panel {
  transform: translate3d(0, 36px, -180px);
  opacity: 0;
}

dialog.is-leaving .dialog-panel {
  opacity: 0;
  pointer-events: none;
}

/* Toasts: stacked buttons and the front card's pausable countdown. */
#toast-region {
  position: fixed;
  top: max(1.5rem, env(safe-area-inset-top));
  right: max(1.5rem, env(safe-area-inset-right));
  z-index: 3000;
  display: grid;
  width: min(22.5rem, calc(100vw - 3rem));
  padding: 0;
  margin: 0;
  pointer-events: none;
}

.toast-announcement[role="status"] {
  display: block;
}

.toast {
  position: relative;
  grid-area: 1 / 1;
  align-self: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16px;
  align-items: start;
  gap: 1rem;
  width: 100%;
  min-height: 5.5rem;
  padding: 1.125rem 1.125rem 1.375rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-toast);
  color: var(--text);
  font-size: var(--fs-meta);
  font-weight: 400;
  line-height: 1.6;
  text-align: left;
  overflow-wrap: anywhere;
  transform: translate3d(0, 0, 0);
  opacity: 1;
  pointer-events: auto;
}

.toast:hover {
  background: color-mix(in srgb, var(--card) 96%, transparent);
  opacity: 1;
}

.toast[data-kind="error"] {
  border-left: 4px solid var(--down);
}

.toast[data-depth="0"] {
  z-index: 3;
}

.toast[data-depth="1"] {
  z-index: 2;
  transform: translate3d(0, 12px, -60px);
  opacity: 0.8;
  pointer-events: none;
}

.toast[data-depth="2"] {
  z-index: 1;
  transform: translate3d(0, 24px, -120px);
  opacity: 0.6;
  pointer-events: none;
}

.toast.is-entering {
  transform: translate3d(0, 36px, -180px);
  opacity: 0;
}

.toast.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.toast-message {
  min-width: 0;
}

.toast-close {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.75;
  stroke-linecap: round;
}

.toast-track {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--line);
}

.toast-progress {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: left;
}

.toast[data-kind="error"] .toast-progress {
  background: var(--down);
}

/* toast.ts starts or restarts this animation; its animationend dismisses it. */
.toast.is-timed .toast-progress {
  animation: toast-countdown 5s linear forwards;
  animation-play-state: var(--toast-countdown-play, running);
}

.toast:hover,
.toast:focus-within,
.toast.is-leaving {
  --toast-countdown-play: paused;
}

@keyframes toast-countdown {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* Segmented controls, including the footer's colour mode. */
.seg-control {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  margin-bottom: 1rem;
}

.seg-control button,
.seg-control a {
  border: 0;
  background: transparent;
  padding: 0.3125rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  transition: background-color var(--t-fast), color var(--t-fast);
}

.seg-control button[aria-pressed="true"],
.seg-control a[aria-current="page"] {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-card);
  font-weight: 600;
}

.theme-mode {
  margin: 0;
}

.theme-mode button {
  padding: 0.25rem 0.625rem;
  font-size: var(--fs-meta);
}

/* Sign-in content; the enclosing panel uses the shared dialog motion. */
dialog.signin {
  width: min(24rem, calc(100vw - 2rem));
}

.si-main h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.si-done {
  display: none;
  text-align: center;
  padding: 1rem 0;
}

dialog.signin.is-done .si-main {
  display: none;
}

dialog.signin.is-done .si-done {
  display: block;
}

.done-check {
  width: 4rem;
  height: 4rem;
  fill: none;
  stroke: var(--up);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.done-check circle {
  stroke: var(--up);
  stroke-width: 1.6;
  opacity: 0.35;
}

.done-check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.is-drawing path {
  animation: draw 520ms var(--ease-out) 120ms both;
}

@keyframes draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

.si-done h2 {
  margin: 0.5rem 0 0.25rem;
}

.key-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spinner {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.si-toggle {
  width: 100%;
  margin-top: 0.5rem;
}

.expand {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 320ms var(--ease-out);
}

.signin.has-passkey .expand {
  grid-template-rows: 0fr;
}

.expand.is-open,
.signin.has-passkey .expand.is-open {
  grid-template-rows: 1fr;
}

.expand-in {
  min-height: 0;
  overflow: hidden;
}

.expand-pad {
  padding: 0.75rem 0.25rem 0.25rem;
  display: grid;
  gap: 0.75rem;
}

.si-fields.is-shake {
  animation: signin-shake 420ms var(--ease-out);
}

@keyframes signin-shake {
  0%,
  100% { transform: none; }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

.si-error {
  margin: 0;
  min-height: 1.25rem;
  font-size: var(--fs-meta);
  color: var(--down);
  font-weight: 600;
}

.si-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

dialog.signin:not(.has-passkey) .si-pk,
dialog.signin:not(.has-passkey) .si-toggle {
  display: none;
}

/* Pages ------------------------------------------------------------------- */

/* Public header and tabs. */
body[data-page="public"] main {
  padding-bottom: 8rem;
}

body[data-page="public"] .site-header {
  border-bottom: 0;
}

.site-header-public .wrap.head-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: baseline;
  gap: 0.5rem 1rem;
}

/* Export text baselines, not the decorative icon's or dot's baseline. */
.site-header-public .brand,
.site-header-public .site-nav,
.site-header-public .verdict-bar,
.site-header-public .live {
  align-items: baseline;
}

.site-header-public .v-icon,
.site-header-public .live-dot {
  align-self: center;
}

/* Balance the private nav's underline space without changing link height. */
.site-header-public .site-nav a {
  padding: 0.3125rem 0;
  border-bottom: 0;
}

.head-grid .site-title {
  justify-self: start;
  min-width: 0;
}

.head-grid #header-status {
  justify-self: center;
  min-width: 0;
  text-align: center;
}

.head-grid .live {
  justify-self: end;
  min-width: 0;
  max-width: 100%;
}

.head-grid .live > :not(.live-dot) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.verdict-bar {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--tone);
}

.v-icon {
  flex: none;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--tone);
  background: var(--tone);
  color: var(--page);
}

.verdict-bar[data-status="UNKNOWN"] .v-icon,
.verdict-bar[data-status="NODATA"] .v-icon {
  background: transparent;
}

.v-icon svg {
  width: 0.75rem;
  height: 0.75rem;
  fill: none;
  stroke: var(--page);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabbar {
  border-bottom: 1px solid var(--line);
}

.tabs {
  position: relative;
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: none;
  background: none;
  border: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--t-fast);
}

.tab:hover,
.tab[aria-current="page"],
.tab[aria-selected="true"] {
  color: var(--text);
  opacity: 1;
}

/* The active link is underlined even before the sliding indicator is placed. */
.tab[aria-current="page"] {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.tabs:has(.tab-ind[style]) .tab[aria-current="page"] {
  box-shadow: none;
}

.tab-ind {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  transition: transform var(--t-med) var(--ease-out),
    width var(--t-med) var(--ease-out);
  pointer-events: none;
}

.tab-panel {
  outline-offset: 4px;
}

.tab-panel > h2.sr-only {
  margin: 0;
}

/* Public overview, incidents and recovery sparks. */
.incidents {
  margin: 1.25rem 0;
}

.inc-card {
  margin-bottom: 0.5rem;
}

.inc-rows {
  display: grid;
}

.inc-row {
  color: var(--text);
  padding: 0.375rem 0;
  overflow-wrap: anywhere;
}

.inc-row:not(:first-child) {
  border-top: 1px solid var(--line);
}

.inc-row:first-child {
  padding-top: 0;
}

.inc-row:last-child {
  padding-bottom: 0;
}

.inc-name {
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.check-wrap {
  position: relative;
  display: inline-flex;
  flex: none;
  vertical-align: -0.1875rem;
  margin-right: 0.375rem;
}

.inc-check {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: var(--up);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body[data-page="public"] .spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.4375rem;
  height: 0.4375rem;
  margin: -0.21875rem 0 0 -0.21875rem;
  border-radius: 50%;
  background: var(--up);
  pointer-events: none;
  animation: spark 800ms var(--ease-out) forwards;
}

@keyframes spark {
  from {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(var(--dx), var(--dy)) scale(0.3);
    opacity: 0;
  }
}

/* Match the cards' spacing; adjacent block margins collapse to one gap. */
body[data-page="public"] #banner,
body[data-page="public"] .banner {
  margin: 1.25rem 0;
}

body[data-page="public"] #banner:empty,
.incidents:not(:has(.inc-card)),
#status-card:empty {
  display: none;
}

#status-card {
  margin: 1.25rem 0;
}

.is-stale-feed #groups,
.is-stale-feed #loc-body {
  opacity: 0.55;
}

.clear-body {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.1875rem 0;
}

.clear-check {
  flex: none;
  width: 3rem;
  height: 3rem;
  fill: none;
  stroke: var(--up);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.clear-check circle {
  stroke-width: 1.6;
  opacity: 0.35;
}

.clear-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

.stale-body {
  color: var(--muted);
}

/* Public Services & sites. */
body[data-page="public"] .group {
  margin-bottom: 1.75rem;
}

body[data-page="public"] .group-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.625rem;
}

.group-head h2 {
  margin: 0;
}

.group-up {
  margin-left: auto;
  font-size: var(--fs-meta);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cards {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

.cards .card {
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.card-name {
  font-weight: 650;
  overflow-wrap: anywhere;
  min-width: 0;
}

.card-foot {
  margin-top: 0.5rem;
  font-size: var(--fs-meta);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chip-pop {
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0.875rem 1rem;
  width: min(19rem, calc(100vw - 1rem));
  height: max-content;
  max-height: calc(100dvh - 1rem);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}

.chip-pop[style] {
  inset: auto;
  margin: 0;
}

.chip-pop:popover-open {
  animation: pop-in 180ms var(--ease-out);
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* Public Locations. An empty globe leaves the server-rendered list alone. */
.loc-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.globe-box {
  position: relative;
  width: 100%;
  max-width: 30rem;
  aspect-ratio: 1;
  margin: 0 auto;
  touch-action: none;
}

.globe-box.is-empty,
.globe-box:empty {
  display: none;
}

.globe-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.globe-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 0.75rem;
  height: 0.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--tone, var(--unknown));
  box-shadow: 0 0 0 2px var(--page);
  cursor: pointer;
  transition: none;
}

.globe-dot:hover {
  opacity: 1;
}

.globe-dot[data-status="UP"] {
  background: var(--up);
  --ring: var(--up);
}

.globe-dot[data-status="PARTIAL"] {
  background: var(--amber);
  --ring: var(--amber);
}

.globe-dot[data-status="DOWN"] {
  background: var(--down);
  --ring: var(--down);
}

.globe-dot[data-status="UNKNOWN"] {
  background: var(--unknown);
  --ring: var(--unknown);
}

.globe-dot.is-focus {
  box-shadow: 0 0 0 2px var(--page),
    0 0 0 5px var(--ring, var(--unknown));
}

.globe-label {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  pointer-events: none;
  text-shadow: 0 0 2px var(--page), 0 0 2px var(--page),
    0 0 4px var(--page), 0 0 4px var(--page), 0 0 6px var(--page);
}

.loc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.loc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}

.loc-row[data-geonameid] {
  cursor: pointer;
}

.loc-row:hover,
.loc-row:focus-visible {
  border-color: var(--line-strong);
  background: var(--surface);
}

.loc-main {
  min-width: 0;
}

.loc-name {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.loc-place {
  font-size: var(--fs-meta);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.loc-place.is-none {
  font-style: italic;
}

.loc-side {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.loc-up {
  min-width: 3.5rem;
  text-align: right;
  font-size: var(--fs-meta);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.attrib {
  margin: 1.5rem 0 0;
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* Dashboard summary, filters and jump badges. */
body[data-page="dashboard"] h1 {
  margin-bottom: 1rem;
}

body[data-page="dashboard"] .banner,
body[data-page="dashboard"] .watch-error {
  margin-bottom: 1rem;
}

.watch-error .err-text {
  font-family: var(--mono);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

body[data-page="dashboard"] .summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 0.875rem;
}

#counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#counts .pill {
  font-size: 0.875rem;
  padding: 0.125rem 0.75rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-left: auto;
}

.search {
  min-width: 0;
}

.search input {
  width: 15rem;
  max-width: 100%;
  padding: 0.4375rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
}

.switch input {
  position: absolute;
  inset: 0 auto 0 0;
  width: 2.25rem;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.switch .track {
  position: relative;
  flex: none;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color var(--t-fast);
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--page);
  transition: transform var(--t-med) var(--spring);
}

.switch input:checked + .track {
  background: var(--accent);
}

.switch input:checked + .track::after {
  transform: translateX(1rem);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body[data-page="dashboard"] .jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

body[data-page="dashboard"] .jump .muted {
  margin-right: 0.25rem;
}

body[data-page="dashboard"] .jump a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  overflow-wrap: anywhere;
}

.jump-badge {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: var(--down);
  color: var(--page);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
  line-height: 1.25rem;
  font-variant-numeric: tabular-nums;
}

body[data-page="dashboard"] section.block {
  margin-bottom: 1.75rem;
  scroll-margin-top: 1rem;
}

body[data-page="dashboard"] section.block > h2 {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.na-grid {
  display: grid;
  gap: 0.875rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr));
}

.na-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.na-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.na-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.na-name:hover,
.tile-name:hover {
  text-decoration: underline;
}

.na-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  color: var(--muted);
  font-size: var(--fs-meta);
  overflow-wrap: anywhere;
}

/* Latest failures are ordinary visible blocks, not disclosure widgets. */
.failure {
  margin-top: 0.75rem;
}

.failure-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.failure-reason {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.failure-error {
  margin: 0.375rem 0 0;
  padding: 0.5rem 0.625rem;
  font-family: var(--mono);
  font-size: var(--fs-meta);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
}

body[data-page="dashboard"] .group {
  margin-bottom: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--page);
  scroll-margin-top: 1rem;
  overflow: hidden;
}

body[data-page="dashboard"] .group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.75rem;
  padding: 0.625rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

body[data-page="dashboard"] .group-head .push {
  margin-left: auto;
}

.tiles {
  display: grid;
  gap: 0.75rem;
  padding: 0.875rem 1rem 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  min-width: 0;
}

.tile-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.tile-name {
  font-weight: 650;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.tile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
}

body[data-page="dashboard"] .stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.25rem;
}

.stat-l {
  display: block;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.stat-v {
  font-size: var(--fs-meta);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-v .muted {
  display: block;
  font-weight: 400;
  font-size: var(--fs-xs);
}

body[data-page="dashboard"] .spark {
  display: block;
  width: 100%;
  height: 1.75rem;
}

.spark-area {
  fill: var(--accent-bg);
  stroke: none;
}

.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.removed-box {
  border: 1px solid var(--down);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  display: grid;
  gap: 0.75rem;
}

.removed-tile {
  opacity: 0.6;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.removed-tile strong {
  font-weight: 650;
  margin-right: 0.5rem;
}

body[data-page="dashboard"] .empty {
  padding: 1.5rem 1rem;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

/* Monitor heading, availability and window control. */
body[data-page="monitor"] main {
  padding-bottom: 7rem;
}

.back {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.mon-head h1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.75rem;
  margin-bottom: 0.25rem;
  font-size: var(--fs-hero);
  overflow-wrap: anywhere;
}

.mon-head .pill {
  font-size: 0.875rem;
  padding: 0.125rem 0.625rem;
}

.mon-head .counter {
  font-size: 1rem;
  font-weight: 500;
  color: var(--tone);
}

.mon-head p {
  margin: 0;
}

body[data-page="monitor"] main section {
  margin-top: 2rem;
}

body[data-page="monitor"] section > h2,
.win-bar h2 {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: var(--fs-meta);
  color: var(--muted);
}

body[data-page="monitor"] .stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  padding: 0.75rem 1rem;
  min-width: 0;
}

.stat-label {
  font-size: var(--fs-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: clamp(1.375rem, 1rem + 1.6vw, 1.875rem);
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: var(--fs-xs);
  color: var(--muted);
  min-height: 1.1em;
}

.strip-caption,
.tl-labels {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: 0.375rem;
}

.win-control {
  position: relative;
  display: inline-grid;
  margin: 0;
  min-width: min(100%, 20rem);
}

.win-control a {
  position: relative;
  z-index: 1;
}

.win-control:has(.win-ind[style]) a[aria-current="page"] {
  background: transparent;
  box-shadow: none;
}

.win-ind {
  position: absolute;
  top: 3px;
  left: 0;
  width: 0;
  height: calc(100% - 6px);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  transition: transform var(--t-med) var(--ease-out),
    width var(--t-med) var(--ease-out);
  pointer-events: none;
}

.win-bar {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.win-bar h2 {
  margin: 0;
}

/* Monitor status timeline. Segment shares are set through the CSSOM. */
.tl {
  display: flex;
  gap: 2px;
  height: 1.25rem;
  border-radius: 999px;
  overflow: hidden;
}

.tl.is-intro {
  animation: tl-in 800ms var(--ease-out) both;
}

@keyframes tl-in {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

.tl-seg {
  flex: 0 0 auto;
  flex-basis: 0;
  min-width: 3px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--up);
  cursor: pointer;
  transition: filter var(--t-fast);
}

.tl-seg[data-status="DOWN"] {
  background: var(--down);
}

.tl-seg[data-status="UNKNOWN"] {
  background: var(--unknown);
}

.tl-seg[data-status="NODATA"] {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--nodata);
  cursor: default;
}

.tl-seg:hover,
.tl-seg:focus-visible {
  filter: brightness(1.12);
  opacity: 1;
}

.tl-seg:focus-visible {
  outline-offset: -2px;
}

/* Monitor chart: the viewBox keeps its aspect ratio and circular markers. */
.chart-figure {
  margin: 0;
}

.chart-box {
  position: relative;
  touch-action: pan-y;
}

.chart-box svg {
  display: block;
  width: 100%;
  height: auto;
}

.ch-grid {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.ch-axis {
  stroke: var(--line-strong);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.ch-lbl {
  fill: var(--muted);
  font-size: var(--fs-xs);
  font-family: inherit;
}

.ch-down {
  fill: var(--down-bg);
}

.ch-max {
  fill: var(--accent-bg);
}

.ch-area {
  fill: var(--accent);
}

.ch-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 1;
  vector-effect: non-scaling-stroke;
}

.ch-line.is-draw {
  animation: draw 900ms var(--ease-out) both;
}

.ch-cross {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}

.ch-dot {
  fill: var(--page);
  stroke: var(--accent);
  stroke-width: 2;
}

.ch-cross,
.ch-dot {
  display: none;
}

.ch-on .ch-cross,
.ch-on .ch-dot {
  display: inline;
}

.chart-cap,
figcaption {
  margin: 0.5rem 0 0;
  font-size: var(--fs-meta);
  color: var(--muted);
}

tr.is-hit {
  background: var(--tone-bg);
  animation: hit-fade 1500ms var(--ease-out) forwards;
}

@keyframes hit-fade {
  0%,
  40% { background-color: var(--tone-bg); }
  100% { background-color: transparent; }
}

.fails {
  display: grid;
  gap: 0.5rem;
}

.fail {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

dl.def {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.5rem 1.5rem;
  margin: 0;
}

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

dl.def dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

dl.def dd.full,
dl.def dt.full {
  grid-column: 1 / -1;
}

dl.def dt.full {
  margin-bottom: -0.25rem;
}

/* Settings sections and form feedback. */
body[data-page="settings"] main {
  padding-bottom: 9rem;
}

body[data-page="settings"] section.block {
  margin: 0 0 2rem;
  scroll-margin-top: 1rem;
}

body[data-page="settings"] section.block > h2,
.msecs-title {
  font-size: 1.125rem;
  margin-bottom: 0.25rem;
}

.lead {
  color: var(--muted);
  font-size: var(--fs-meta);
  margin: 0 0 0.75rem;
}

body[data-page="settings"] .jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.5rem;
  margin: 0 0 1.5rem;
}

body[data-page="settings"] .jump .meta {
  margin-right: 0.25rem;
}

body[data-page="settings"] .jump a {
  padding: 0.125rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
  transition: border-color var(--t-fast), background-color var(--t-fast);
}

body[data-page="settings"] .jump a:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.fld select,
.fld input[type="text"],
.banner-form textarea {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--page);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.fld {
  min-width: 0;
}

.fld input[type="text"] {
  padding-right: 1.5rem;
}

.fld select {
  padding-right: 2rem;
}

body[data-page="settings"] [aria-invalid="true"] {
  border-color: var(--down) !important;
  box-shadow: 0 0 0 1px var(--down);
}

.fld > label,
.fld > .lbl {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-bottom: 0.1875rem;
}

.ctl {
  position: relative;
}

/* The settings dirty marker is separate from the history strip segments. */
body[data-page="settings"] .ctl > .dot {
  display: none;
  position: absolute;
  right: 0.6rem;
  top: 50%;
  width: 0.4375rem;
  height: 0.4375rem;
  margin-top: -0.21875rem;
  border-radius: 50%;
  background: var(--amber);
  pointer-events: none;
}

body[data-page="settings"] .ctl.is-dirty > .dot {
  display: block;
  animation: dot-in var(--t-fast) var(--spring);
}

@keyframes dot-in {
  from { transform: scale(0); }
}

.ok {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  margin-top: -0.5rem;
  color: var(--up);
  opacity: 0;
  pointer-events: none;
}

.ctl.sel .ok {
  right: 1.75rem;
}

.ok svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ok.is-on {
  animation: ok-pop 1200ms ease both;
}

@keyframes ok-pop {
  0% { opacity: 0; transform: scale(0.3); }
  14% { opacity: 1; transform: scale(1.25); }
  24% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

body[data-page="settings"] .is-shake {
  animation: field-shake 400ms ease;
}

@keyframes field-shake {
  15% { transform: translateX(-5px); }
  35% { transform: translateX(5px); }
  55% { transform: translateX(-3px); }
  75% { transform: translateX(2px); }
}

/* Settings banner editor and live preview. */
.banner-form {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
}

.banner-form textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.45;
  display: block;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.25rem;
  font-weight: 600;
  font-size: 0.9375rem;
}

body[data-page="settings"] .counter {
  font-weight: 400;
  font-size: var(--fs-meta);
  color: var(--muted);
}

body[data-page="settings"] .counter.is-near {
  color: var(--amber);
}

body[data-page="settings"] .counter.is-full {
  color: var(--down);
}

body[data-page="settings"] .hint {
  margin: 0.25rem 0 0;
}

.sev {
  position: relative;
  width: 100%;
  max-width: 20rem;
  margin: 0.25rem 0 1rem;
}

.sev .thumb-bg {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 3);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform var(--t-med) var(--spring);
}

.sev button {
  position: relative;
  z-index: 1;
}

.sev button[aria-pressed="true"] {
  background: transparent;
  box-shadow: none;
}

.sev-wrap {
  margin: 0;
}

.preview {
  min-width: 0;
}

.preview-label {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.banner-empty {
  padding: 0.875rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  margin: 0;
}

.banner-actions {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Settings group and monitor rows, drag handles and keyboard ordering. */
.grow,
.mrow {
  display: grid;
  align-items: end;
  gap: 0.5rem 0.75rem;
  padding: 0.5rem;
  margin: 0 0 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}

.grow {
  grid-template-columns: 2rem minmax(0, 1fr) minmax(0, 1.4fr) 5rem auto auto;
}

.mrow {
  grid-template-columns: 2rem minmax(0, 9rem) minmax(0, 1.5fr)
    minmax(0, 1fr) 4.5rem 4.5rem auto;
}

.mrow.is-dragging,
.grow.is-dragging {
  position: fixed;
  z-index: 1200;
  margin: 0;
  pointer-events: none;
  transform: scale(1.015);
  box-shadow: var(--shadow-pop);
  border-color: var(--accent);
  transition: none;
}

.mph {
  margin-bottom: 0.5rem;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
}

body.is-dragging-body {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing;
}

body.is-dragging-body * {
  cursor: grabbing !important;
}

.handle,
.ibtn {
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: color var(--t-fast), background-color var(--t-fast),
    border-color var(--t-fast);
}

.handle {
  border: 0;
  cursor: grab;
  touch-action: none;
}

.handle:hover,
.ibtn:hover {
  color: var(--text);
  background: var(--surface);
  opacity: 1;
}

.ibtn {
  border: 1px solid var(--line);
  background: var(--page);
}

.ibtn[aria-disabled="true"] {
  opacity: 0.35;
  cursor: default;
}

.ibtn[aria-disabled="true"]:hover {
  color: var(--muted);
  background: var(--page);
}

.handle svg,
.ibtn svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.moves {
  display: flex;
  gap: 0.25rem;
}

.wname {
  font-family: var(--mono);
  font-size: var(--fs-meta);
  color: var(--muted);
  overflow-wrap: anywhere;
  padding-bottom: 0.5rem;
}

.del {
  min-width: 5.75rem;
  transition: background-color var(--t-fast), border-color var(--t-fast),
    color var(--t-fast);
}

.del.is-armed,
.del.is-armed:hover {
  background: var(--down);
  border-color: var(--down);
  color: var(--page);
  opacity: 1;
}

.msec {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.75rem 0.25rem;
  margin-bottom: 1rem;
  scroll-margin-top: 1rem;
}

.msec-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.msec-head h2 {
  margin: 0;
}

body[data-page="settings"] .empty {
  margin: 0 0 0.75rem;
  font-size: var(--fs-meta);
}

.mlist:has(.mrow:not(.is-dragging), .mph) > .empty,
.glist:has(.grow) > .empty {
  display: none;
}

.addgroup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5rem auto;
  gap: 0.5rem 0.75rem;
  align-items: end;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

.addgroup .fld input {
  padding-right: 0.625rem;
}

.eye-toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background-color var(--t-fast);
}

.eye-toggle:hover:not(:disabled) {
  background: var(--surface);
  opacity: 1;
}

.eye-toggle:focus-visible {
  border-radius: 50%;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.eye-toggle:disabled {
  cursor: default;
}

.eye-toggle svg {
  grid-area: 1 / 1;
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  transition: opacity var(--t-fast) ease,
    transform var(--t-fast) var(--ease-out);
}

.eye-toggle .e-on {
  color: var(--accent);
}

.eye-toggle .e-off {
  color: var(--muted);
}

.eye-toggle[aria-pressed="true"] .e-off,
.eye-toggle[aria-pressed="false"] .e-on {
  opacity: 0;
  transform: scale(0.6);
}

.f-pub .ctl {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
}

.f-pub .ok {
  position: static;
  margin: 0;
  flex: none;
}

/* Settings location combobox. */
.f-loc .ctl input {
  padding-right: 3.5rem;
}

.f-loc .ok {
  right: 0.5rem;
}

.cb-clear {
  position: absolute;
  right: 1.75rem;
  top: 50%;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: -0.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: color var(--t-fast), background-color var(--t-fast);
}

.cb-clear:hover {
  color: var(--text);
  background: var(--surface);
  opacity: 1;
}

.cb-clear:focus-visible {
  border-radius: 50%;
}

.cb-list {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  left: 0;
  width: max(100%, 20rem);
  max-width: calc(100vw - 2rem);
  max-height: 17rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-pop);
}

.cb-list.is-anim {
  animation: cb-in var(--t-fast) var(--ease-out);
}

@keyframes cb-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.cb-opt {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: calc(var(--radius-sm) - 3px);
  cursor: pointer;
}

.cb-opt.is-active,
.cb-opt[aria-selected="true"] {
  background: var(--accent-bg);
}

.cb-opt .cb-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cb-opt .cb-main b {
  font-weight: 700;
}

.cb-opt .cb-reg,
.cb-opt .cb-pop {
  color: var(--muted);
  font-size: var(--fs-meta);
}

.cb-opt .cb-pop {
  flex: none;
  font-variant-numeric: tabular-nums;
}

.cb-none {
  padding: 0.5rem;
  color: var(--muted);
  font-size: var(--fs-meta);
}

/* Settings read-only removed monitors and sliding save bar. */
body[data-page="settings"] .removed {
  border: 1px solid var(--down);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

body[data-page="settings"] .removed fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  opacity: 0.6;
  color: var(--muted);
}

body[data-page="settings"] .removed :disabled,
body[data-page="settings"] .removed label {
  cursor: not-allowed;
}

.removed .rname {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-start;
  padding-bottom: 0.5rem;
}

.removed .mrow {
  margin-bottom: 0;
}

.removed .note {
  margin: 0 0 0.5rem;
}

.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--bar-bottom, max(1rem, env(safe-area-inset-bottom)));
  z-index: 1400;
  pointer-events: none;
  transform: translateY(calc(100% + 6rem));
  visibility: hidden;
  transition: transform var(--t-med) var(--ease-out),
    visibility 0s linear var(--t-med);
}

.savebar.is-open {
  transform: none;
  visibility: visible;
  transition: transform var(--t-med) var(--spring), visibility 0s;
}

.savebar-in {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.625rem 0.75rem 0.625rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-pop);
}

/* Account, users, invitation and error pages. */
body[data-page="account"] main > section,
body[data-page="users"] main > section {
  margin-top: 2rem;
  margin-bottom: 2.25rem;
}

body[data-page="account"] .stack {
  max-width: 30rem;
}

.passkeys,
.users {
  display: grid;
  gap: 0.75rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.passkey,
.user {
  display: block;
  padding: 0.875rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.passkey .key-icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--accent);
}

.passkey .card-head {
  justify-content: flex-start;
}

.passkey-label,
.user-head {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.passkey-meta,
.user-meta {
  display: block;
  color: var(--muted);
  font-size: var(--fs-meta);
  overflow-wrap: anywhere;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.copy-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  min-width: 0;
}

.copy-row input {
  flex: 1 1 0;
  min-width: 0;
}

.copy-row button {
  flex: none;
}

#invite-link {
  width: 100%;
}

body[data-page="invite"] .panel,
body[data-page="error"] .panel {
  overflow-wrap: anywhere;
}

/* Responsive layouts ------------------------------------------------------ */

@media (min-width: 48rem) {
  .loc-layout {
    grid-template-columns: minmax(0, 30rem) minmax(0, 1fr);
  }

  .loc-layout:has(> .globe-box:empty),
  .loc-layout:has(> .globe-box.is-empty) {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (min-width: 52rem) {
  .banner-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
}

@media (max-width: 52rem) {
  .site-footer .wrap {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    text-align: center;
  }

  .site-footer .version,
  .site-footer .theme-mode {
    justify-self: center;
  }

  .mrow {
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    grid-template-areas: "h w m" "n n n" "g g o" "p p p";
    align-items: end;
  }

  .mrow > .handle {
    grid-area: h;
    align-self: center;
  }

  .mrow > .wname {
    grid-area: w;
    align-self: center;
    padding: 0;
  }

  .mrow > .moves {
    grid-area: m;
    align-self: center;
  }

  .mrow > .f-name {
    grid-area: n;
  }

  .mrow > .f-group {
    grid-area: g;
  }

  .mrow > .f-order {
    grid-area: o;
    width: 5rem;
  }

  .mrow > .f-pub {
    grid-area: p;
  }

  .removed .mrow > .rname {
    grid-area: w;
  }

  .grow {
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    grid-template-areas: "h n m" "l l l" "o o d";
  }

  .grow > .handle {
    grid-area: h;
    align-self: center;
  }

  .grow > .f-name {
    grid-area: n;
  }

  .grow > .f-loc {
    grid-area: l;
  }

  .grow > .f-order {
    grid-area: o;
    width: 5rem;
  }

  .grow > .moves {
    grid-area: m;
    align-self: center;
  }

  .grow > .del {
    grid-area: d;
  }

  .addgroup {
    grid-template-columns: minmax(0, 1fr) 5rem;
  }

  .addgroup .btn,
  .addgroup > button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 40rem) {
  .filters {
    margin-left: 0;
    width: 100%;
  }

  .search {
    flex: 1 1 100%;
  }

  .search input {
    width: 100%;
  }

  body[data-page="dashboard"] .group-head .push {
    margin-left: 0;
  }

  body[data-page="monitor"] .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  dl.def {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.125rem;
  }

  dl.def dd {
    margin-bottom: 0.5rem;
  }
}

@media (max-width: 36rem) {
  main,
  main.wrap {
    padding-top: 1rem;
  }

  .panel.narrow {
    margin-top: 1rem;
  }

  .site-header .wrap > .site-nav {
    flex-basis: 100%;
  }

  .site-header .wrap.head-grid {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title live" "verdict verdict";
  }

  .site-header .wrap.head-grid:has(> .brand) {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  }

  .head-grid > .site-title,
  .head-grid > .brand {
    grid-area: title;
  }

  .head-grid .live {
    grid-area: live;
  }

  .head-grid #header-status {
    grid-area: verdict;
    justify-self: center;
  }

  .facts {
    flex-direction: column;
  }
}

@media (max-width: 30rem) {
  .wrap,
  main {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  #toast-region {
    top: max(1rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
    width: calc(100vw - 2rem);
  }

  .dialog-panel {
    padding: 1.5rem;
  }

  input,
  select,
  textarea {
    font-size: 1rem;
  }

  .loc-row {
    flex-wrap: wrap;
    gap: 0.375rem;
  }

  .loc-side {
    margin-left: auto;
  }

  .savebar-in {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .savebar-in > button {
    margin-left: auto;
  }

  .copy-row {
    flex-wrap: wrap;
  }

  .copy-row input {
    flex-basis: 100%;
  }

  .copy-row button {
    margin-left: auto;
  }
}
