@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ground: #0b0f14;
  --tile: #141b24;
  --seam: #263140;
  --ink: #e6edf3;
  --dim: #8b96a3;
  --amber: #ffb000;
  --ok: #3fd16a;
  --careful: #4aa3ff;
  --warning: #d55fde;
  --critical: #ff4d4d;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(16px, 3vw, 40px);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html {
  background: var(--ground);
  scrollbar-color: var(--seam) var(--ground);
}

/* One type size for the whole page, as in a terminal: rank comes from
   weight, case and reverse video, never from size. */
body {
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.6 "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-variant-ligatures: none;
  -webkit-text-size-adjust: 100%;
}
@media (max-width: 480px) { body { font-size: 14px; } }

h1, h2, b { font: inherit; font-weight: 700; }
::selection { background: var(--amber); color: var(--ground); }

a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--seam); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--amber); }
:focus-visible { outline: 1px solid var(--amber); outline-offset: 3px; }

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px var(--gutter) 28px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.dim { color: var(--dim); }
.rv { background: var(--ink); color: var(--ground); padding: 0 0.4em; }
.num { margin-left: auto; text-align: right; white-space: nowrap; }

.ok { color: var(--ok); }
.car { color: var(--careful); }
.warn { color: var(--warning); }
.crit { color: var(--critical); }

/* ---- lamps ---- */
.lamp {
  display: inline-block;
  width: 0.65em;
  height: 0.65em;
  margin-right: 0.6em;
  background: var(--dim);
  vertical-align: 0.02em;
}

/* ---- top line ---- */
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--seam);
}
.live { display: flex; align-items: baseline; gap: 0 0.6em; white-space: nowrap; }
.live .lamp { margin-right: 0; }
body[data-conn="live"] .live .lamp { background: var(--ok); }
body[data-conn="live"] #live-label { color: var(--ok); }
body[data-conn="stale"] .live .lamp,
body[data-conn="reconnecting"] .live .lamp { background: transparent; outline: 1px dashed var(--dim); outline-offset: -1px; }
body[data-conn="stale"] #live-label,
body[data-conn="reconnecting"] #live-label { color: var(--dim); }

/* ---- host strip ---- */
.strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--seam);
}
.cell { padding: 14px 20px 16px; }
.cell:first-child { padding-left: 0; }
.cell:last-child { padding-right: 0; }
.cell + .cell { border-left: 1px solid var(--seam); }
.cell { min-width: 0; }
.cell-head { display: flex; flex-wrap: wrap; gap: 0 0.6em; align-items: baseline; margin-bottom: 8px; }

/* ---- meters ---- */
.meter {
  position: relative;
  height: 10px;
  background: var(--ground);
  border: 1px solid var(--seam);
  overflow: hidden;
}
.strip .meter { background: var(--tile); }
.meter i {
  position: absolute;
  inset: 0;
  background: currentColor;
  transform-origin: left center;
  transform: scaleX(var(--v, 0));
  transition: transform 900ms var(--ease);
}
body[data-conn="stale"] .meter i {
  background: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 10px);
}

/* ---- banner ---- */
.banner {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 1em;
  align-items: baseline;
  padding: 20px 0 18px;
}
.banner[data-tone="ok"] #banner-head { background: var(--ok); }
.banner[data-tone="crit"] #banner-head { background: var(--critical); }
.banner[data-tone="stale"] #banner-head { background: var(--dim); }
#banner-body { color: var(--dim); }
.banner[data-tone="crit"] #banner-body { color: var(--ink); }

/* ---- stations ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-content: start;
  margin-bottom: 28px;
}
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cell { padding: 12px 14px 14px 0; }
  .cell:nth-child(2n) { padding: 12px 0 14px 14px; }
  .cell:nth-child(3) { border-left: 0; }
  .cell:nth-child(n + 3) { border-top: 1px solid var(--seam); }
}

.st {
  background: var(--tile);
  border: 1px solid var(--seam);
  border-radius: 2px;
  padding: 16px 18px 18px;
  transition: border-color 400ms var(--ease);
}
.st-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1em; }
.st-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-no { color: var(--dim); }
.st-clock { white-space: nowrap; color: var(--dim); }
/* The note tucks under the name; without one, meters sit 12px below it. */
.st-top { margin-bottom: 12px; }
.st-note { color: var(--dim); margin: -10px 0 12px; }
.row { display: grid; grid-template-columns: 3.4em 1fr 3.6em; gap: 10px; align-items: center; }
.row + .row { margin-top: 6px; }

.st[data-status="up"] .lamp { background: var(--ok); }
.st[data-status="up"] .st-clock { color: var(--amber); font-weight: 700; }

.st[data-status="down"] { border-color: var(--critical); }
.st[data-status="down"] .lamp { background: var(--critical); }
.st[data-status="down"] .st-label { text-decoration: line-through; text-decoration-color: var(--critical); text-decoration-thickness: 2px; }
.st[data-status="down"] .st-clock { color: var(--critical); font-weight: 700; }

/* A down station's last readings are shown, but never in health colours:
   the red frame owns the tile. */
.st[data-status="down"] .meter { color: var(--dim); }
.st[data-status="down"] .row .num { color: var(--dim); }

.st[data-status="unknown"] .lamp { background: transparent; outline: 1px dashed var(--dim); outline-offset: -1px; }

/* SERVICES cell: one segment per service. */
.meter.segs { display: flex; gap: 2px; background: none; border: 0; overflow: visible; }
.strip .meter.segs { background: none; }
.segs span { flex: 1; background: var(--ok); }
.segs span.down { background: var(--critical); }
.segs span.unknown { background: none; border: 1px dashed var(--dim); }

/* No load reading: dashed empty track. */
.meter[data-empty] { border-style: dashed; }
.row:has(.meter[data-empty]) .num { color: var(--dim); }


/* ---- live updates (Bluesky) ---- */
.updates { margin: 8px 0 28px; }
.updates-head { padding-bottom: 10px; border-bottom: 1px solid var(--seam); }
.updates-list { list-style: none; }
.up-item {
  display: grid;
  grid-template-columns: 15em minmax(0, 1fr) auto;
  gap: 4px 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--seam);
}
.up-time { font-weight: 700; }
.up-text { max-width: 75ch; white-space: pre-wrap; overflow-wrap: anywhere; }
.up-item.fresh .up-time::after { content: "NEW"; color: var(--ground); background: var(--ink); padding: 0 0.4em; margin-left: 0.6em; }
.updates-empty { padding: 12px 0; }
@media (max-width: 700px) {
  .up-item { grid-template-columns: minmax(0, 1fr); }
}

/* ---- footer ---- */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 24px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--seam);
}

.legend { display: flex; flex-wrap: wrap; gap: 0 1.4em; }
.sw { display: inline-block; width: 0.65em; height: 0.65em; margin-right: 0.5em; background: currentColor; }
.legend .ok, .legend .car, .legend .warn, .legend .crit { color: inherit; }
.sw.ok { background: var(--ok); }
.sw.car { background: var(--careful); }
.sw.warn { background: var(--warning); }
.sw.crit { background: var(--critical); }

@media (max-width: 480px) {
  .cell { padding: 10px 10px 12px 0; }
  .cell:nth-child(2n) { padding: 10px 0 12px 10px; }
  .cell-head .dim { display: none; }
  #h-load { flex-basis: 100%; text-align: left; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .meter i, .st { transition: none; }
}
