/* ============================================================
   anx testbed
   Monochrome by intent: black, white, and the greys between.
   Colour is reserved for state (stale / fault), nothing else.
   ============================================================ */

/* --- Wordmark face -----------------------------------------
   Drop PowerrRegular into assets/fonts/. woff2 is listed first
   because it is ~60% the size of the ttf over the wire; the ttf
   alone works fine if you skip the conversion.
   ---------------------------------------------------------- */
@font-face {
  font-family: 'Powerr';
  src: url('/assets/fonts/PowerrRegular.woff2') format('woff2'),
       url('/assets/fonts/PowerrRegular.ttf')   format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------ tokens */
:root {
  --bg:          #000000;
  --bg-raised:   #0b0b0b;
  --bg-card:     #101010;
  --bg-hover:    #171717;
  --line:        #262626;
  --line-strong: #3d3d3d;

  --ink:         #ffffff;
  --ink-muted:   #a3a3a3;
  --ink-faint:   #6b6b6b;

  --ok:          #ffffff;
  --stale:       #d4a017;
  --fault:       #e05252;

  --font-mark:   'Powerr', 'Helvetica Neue', Arial, sans-serif;
  --font-ui:     ui-sans-serif, -apple-system, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
  --font-mono:   ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo,
                 Consolas, monospace;

  --step-0:  0.8125rem;
  --step-1:  0.9375rem;
  --step-2:  1.125rem;
  --step-3:  1.5rem;
  --step-4:  2rem;

  --gap:        1rem;
  --pad:        1.25rem;
  --radius:     2px;   /* squares mean squares */
  --header-h:   60px;

  --ease:  cubic-bezier(0.2, 0, 0.2, 1);
  --shell: min(1180px, 100% - 2.5rem);
}

/* Light mode is a courtesy, not the design target. */
:root[data-theme='light'] {
  --bg:          #ffffff;
  --bg-raised:   #fafafa;
  --bg-card:     #f4f4f4;
  --bg-hover:    #ececec;
  --line:        #dcdcdc;
  --line-strong: #b8b8b8;
  --ink:         #000000;
  --ink-muted:   #555555;
  --ink-faint:   #8a8a8a;
  --ok:          #000000;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--step-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
canvas { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }
a:where(.empty-state a) {
  text-decoration: underline;
  text-underline-offset: 2px;
}

code, .mono { font-family: var(--font-mono); font-size: 0.9em; }

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* The `hidden` attribute, made reliable.
 *
 * `[hidden] { display: none }` lives in the UA stylesheet, so *any* author
 * `display` declaration beats it no matter where it sits or how specific it is
 * — and this sheet sets `display` on most of what the page toggles: `.form`,
 * `.btn`'s flex parents, the chart tooltip. Every element JS hides by attribute
 * would need its own `[hidden]` companion rule, and the ones without it fail
 * silently, staying on screen while the code that hid them looks correct. That
 * cost a day on the firmware update button.
 *
 * `!important` because the whole point is to outrank a later, more specific
 * `display`. Nothing in this app wants a visible `[hidden]` element. */
[hidden] { display: none !important; }

/* Visually hidden but available to assistive tech. */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.5rem 0.875rem;
  background: var(--ink);
  color: var(--bg);
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* ------------------------------------------------------------ header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  width: var(--shell);
  margin-inline: auto;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.site-header__back {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: -6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-muted);
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.site-header__back:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}
.site-header__back svg { width: 18px; height: 18px; }

/* The wordmark. Lowercase always — it is set in the type, not the CSS,
   but text-transform guards against a stray capital in a template. */
.wordmark {
  display: inline-flex;
  align-items: baseline;
  line-height: 1;
}
.wordmark__text {
  font-family: var(--font-mark);
  font-size: 2.875rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--ink);
}

.site-header__status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* signed-in identity + sign out */
.signout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.signout__who {
  font-size: var(--step-0);
  color: var(--ink-muted);
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signout__btn {
  padding: 0.3rem 0.6rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-muted);
  font-size: var(--step-0);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s var(--ease), border-color 0.12s var(--ease);
}
.signout__btn:hover { color: var(--ink); border-color: var(--line-strong); }

/* connection pill */
.conn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--step-0);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.conn__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: none;
}
.conn[data-state='online'] { color: var(--ink); border-color: var(--line-strong); }
.conn[data-state='online'] .conn__dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}
.conn[data-state='connecting'] .conn__dot {
  background: var(--stale);
  animation: pulse 1.1s ease-in-out infinite;
}
.conn[data-state='error'] { color: var(--fault); border-color: var(--fault); }
.conn[data-state='error'] .conn__dot { background: var(--fault); }

/*
 * A firmware update in progress.
 *
 * Pulsing like 'connecting' rather than sitting still, because it is the same
 * kind of claim: something is happening and the next state is not yet known.
 * Full-strength ink rather than muted, though — unlike a connection that is
 * merely settling, this is a deliberate operation the user started and should
 * be able to find at a glance across a page of consoles.
 */
.conn[data-state='updating'] { color: var(--ink); border-color: var(--line-strong); }
.conn[data-state='updating'] .conn__dot {
  background: var(--accent, var(--stale));
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* ------------------------------------------------------------ layout */
.site-main {
  flex: 1;
  width: var(--shell);
  margin-inline: auto;
  padding: 2rem 0 4rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.site-footer__inner {
  width: var(--shell);
  margin-inline: auto;
  padding: 1.25rem 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.site-footer__mark {
  font-family: var(--font-mark);
  font-size: 1.125rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--ink-faint);
}
.site-footer__meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
  text-align: right;
  word-break: break-all;
}

/* ------------------------------------------------------------ hero */
.hero { margin-bottom: 1.75rem; }
.hero__title {
  font-size: var(--step-3);
  font-weight: 500;
  letter-spacing: -0.02em;
}
.hero__place {
  margin-top: 0.15rem;
  color: var(--ink-muted);
  font-size: var(--step-1);
}
.hero__sub {
  margin-top: 0.25rem;
  color: var(--ink-muted);
  font-size: var(--step-1);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------- location cards */
/* Wider than the sensor grid and not square: a location card holds two lines
   of prose and a pair of counts, none of which want a 1:1 box. */
.location-card-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.loc-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 11rem;
  padding: var(--pad);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: background 0.15s var(--ease),
              border-color 0.15s var(--ease),
              transform 0.15s var(--ease);
}
.loc-card:hover {
  background: var(--bg-hover);
  border-color: var(--line-strong);
  transform: translateY(-2px);
}
.loc-card:active { transform: translateY(0); }

/* The corner badge. Absolute rather than a flex sibling of the title so a long
   location description wraps under it instead of squeezing it. */
.loc-card__status {
  position: absolute;
  top: var(--pad);
  right: var(--pad);
}

/* Reserve the badge's lane, so a description never runs beneath it. */
.loc-card__head { padding-right: 6.5rem; }

.loc-card__title {
  font-size: var(--step-2);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.loc-card__place {
  margin-top: 0.2rem;
  color: var(--ink-muted);
  font-size: var(--step-0);
}

.loc-card__stats {
  display: flex;
  gap: 2rem;
}
.loc-card__stat dt {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.loc-card__stat dd {
  margin-top: 0.15rem;
  font-size: var(--step-3);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* A figure we do not have yet. Recedes rather than disappears, so the row keeps
   its shape and the dash does not read as a value of its own. */
.loc-card__stat dd.is-pending,
.console__count.is-pending {
  color: var(--ink-faint);
}

.loc-card--unplaced { border-style: dashed; }

/* ------------------------------------------------------- console sections */
/* One per console at the location, stacked. The rule above each after the
   first is what separates two consoles' grids without a heavy box around
   either. */
.console + .console {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

/* The badge sits under the console's name and sensor count rather than opposite
   it, at every width. Ranged against the far edge it was a long way from the
   thing it describes on a wide screen, and it read as page furniture; directly
   beneath, it reads as belonging to this console — which is the whole point now
   that a location can hold several. */
.console__head {
  display: flex;
  /*flex-direction: column;*/
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.console__name {
  font-size: var(--step-2);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.console__meta {
  margin-top: 0.15rem;
  display: flex;
  gap: 0.5rem;
  font-size: var(--step-0);
  color: var(--ink-faint);
}
.console__meta > * + *::before {
  content: '·';
  margin-right: 0.5rem;
}
.console__status { flex: none; }
.console__empty {
  color: var(--ink-muted);
  font-size: var(--step-0);
}

/* ------------------------------------------------------------ card grid */
.card-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* The card is square. aspect-ratio does the work; the body flexes so a long
   sensor name never pushes the reading out of the box. */
.card {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
  padding: var(--pad);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background 0.15s var(--ease),
              border-color 0.15s var(--ease),
              transform 0.15s var(--ease);
}

.card:hover {
  background: var(--bg-hover);
  border-color: var(--line-strong);
  transform: translateY(-2px);
}
.card:active { transform: translateY(0); }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card__kind {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Health is never colour-alone: stale and fault carry a visible word beside
   the dot, and "live" keeps the same text for screen readers. */
.card__health {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex: none;
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.card__health-dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: none;
}
.card__health[data-state='stale'] { color: var(--stale); }
.card__health[data-state='fault'] { color: var(--fault); }
.card__health[data-state='live']  .card__health-dot { background: var(--ok); }
.card__health[data-state='stale'] .card__health-dot { background: var(--stale); }
.card__health[data-state='fault'] .card__health-dot { background: var(--fault); }

.card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.card__reading {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  min-width: 0;
}
/* Proportional figures on purpose: tabular-nums gives every digit the width
   of a 0, which reads loose at display sizes. Tabular is for columns. */
.card__value {
  font-size: clamp(1.75rem, 4.2vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card__unit {
  font-size: var(--step-1);
  color: var(--ink-muted);
  white-space: nowrap;
}

/* Sparkline sits under the reading, bleeding to the card edges. */
.card__spark {
  width: calc(100% + var(--pad) * 2);
  margin-left: calc(var(--pad) * -1);
  height: 44px;
  margin-top: 0.625rem;
  opacity: 0.7;
}

.card__foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: var(--step-0);
  min-width: 0;
}
.card__name {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card__age {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: none;
}

/* stale cards recede rather than shout */
.card[data-health='stale'] .card__value { color: var(--ink-muted); }
.card[data-health='fault'] { border-color: color-mix(in srgb, var(--fault) 45%, var(--line)); }

.card--skeleton {
  background: linear-gradient(100deg,
    var(--bg-card) 30%, var(--bg-hover) 50%, var(--bg-card) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
  pointer-events: none;
}
@keyframes shimmer {
  from { background-position: 120% 0; }
  to   { background-position: -60% 0; }
}

/* ------------------------------------------------------------ detail */
.detail {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.detail__head { display: flex; flex-direction: column; gap: 0.2rem; }
.detail__kind {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.detail__name {
  font-size: var(--step-4);
  font-weight: 500;
  letter-spacing: -0.02em;
}
.detail__id { color: var(--ink-faint); word-break: break-all; }

.detail__live {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.reading { display: flex; align-items: baseline; gap: 0.375rem; }

/* The one hero figure on the page. Same sans as everything else — a display
   face here reads as decoration — and proportional figures, not tabular. */
.reading__value {
  font-size: clamp(3rem, 9vw, 4.5rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.95;
}
.reading__unit { font-size: var(--step-3); color: var(--ink-muted); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, auto));
  gap: 1.5rem;
}
.stat dt {
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.stat dd {
  margin-top: 0.15rem;
  font-size: var(--step-2);
}

/* ------------------------------------------------------------ panel */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem var(--pad);
  border-bottom: 1px solid var(--line);
}
.panel__title {
  font-size: var(--step-1);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.panel__body { padding: var(--pad); }
.panel__note {
  margin-top: 0.875rem;
  font-size: var(--step-0);
  color: var(--ink-faint);
}
.panel__scope {
  font-weight: 400;
  color: var(--ink-faint);
}

/* ------------------------------------------------------------ toolbar
   One filter row, above everything it scopes. */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-wrap: wrap;
  padding-bottom: 0.25rem;
}
.toolbar__note {
  font-size: var(--step-0);
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ chart */
.chart-wrap {
  position: relative;
  margin: 0;
}
.chart {
  width: 100%;
  height: auto;
  /* The canvas draws its own axis band, so the box already includes it. */
  aspect-ratio: 960 / 300;
  cursor: crosshair;
  touch-action: pan-y;
}

/* Refetch keeps the frame: hold the previous render, no skeleton flash. */
[data-history-panel].is-loading .chart-wrap,
[data-history-panel].is-loading .table-wrap {
  opacity: 0.45;
  transition: opacity 0.15s var(--ease);
}

/* `display: flex` below would beat the UA's `[hidden] { display: none }` on
   specificity, leaving an empty bordered box parked in the corner. */
.chart-tip[hidden] { display: none; }

.chart-tip {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, calc(-100% - 12px));
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.35rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  pointer-events: none;
  white-space: nowrap;
}
/* Value leads, label follows — the reader has the series and wants the number. */
.chart-tip__value {
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--ink);
}
.chart-tip__meta {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--ink-muted);
}

/* ------------------------------------------------- table view (chart twin) */
.table-wrap { max-height: 22rem; overflow-y: auto; overscroll-behavior: contain; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums; /* columns of numbers: tabular is right here */
}
.data-table th,
.data-table td {
  padding: 0.3rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  font-weight: 400;
  font-size: var(--step-0);
}
.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-raised);
  color: var(--ink-faint);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom-color: var(--line);
}
.data-table tbody th { color: var(--ink-muted); font-family: var(--font-mono); }
.data-table td { color: var(--ink); }
.data-table tbody tr:hover { background: var(--bg-hover); }

/* segmented range control */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.seg__btn {
  padding: 0.3rem 0.7rem;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  font-size: var(--step-0);
  color: var(--ink-muted);
  cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.seg__btn:first-child { border-left: 0; }
.seg__btn:hover { background: var(--bg-hover); color: var(--ink); }
.seg__btn.is-active { background: var(--ink); color: var(--bg); }

/* ------------------------------------------------------------ forms */
/* `display: flex` here is what used to defeat `hidden` on the firmware update
   form; the global `[hidden]` rule near the top now covers it, and every other
   element this sheet gives a `display` to. */
.form { display: flex; flex-direction: column; gap: var(--gap); }

.field { display: flex; flex-direction: column; gap: 0.375rem; max-width: 22rem; }
.field label {
  font-size: var(--step-0);
  color: var(--ink-muted);
}
.field__row { display: flex; align-items: center; gap: 0.5rem; }
.field__suffix { font-size: var(--step-0); color: var(--ink-faint); }

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  max-width: none;
}
.field--inline label { color: var(--ink); }

/* Every text-ish input, not just the two the sensor form happens to use —
   omitting password left it rendering as a white browser-default box. */
input[type='text'],
input[type='number'],
input[type='password'],
input[type='email'],
input[type='search'],
input[type='url'],
input:not([type]) {
  width: 100%;
  padding: 0.5rem 0.625rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
input[type='text']:focus,
input[type='number']:focus,
input[type='password']:focus,
input[type='email']:focus,
input[type='search']:focus,
input[type='url']:focus,
input:not([type]):focus {
  border-color: var(--line-strong);
  outline-offset: 1px;
}
input::placeholder { color: var(--ink-faint); }

/* Chrome paints autofilled fields with its own pale yellow, which is jarring
   on a black surface. There is no property to disable it; a long inset shadow
   is the standard way to repaint the field. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 100px var(--bg) inset;
  caret-color: var(--ink);
  transition: background-color 9999s ease-out 0s;
}

input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--ink);
  flex: none;
}

.form__actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}
.form__status {
  font-size: var(--step-0);
  color: var(--ink-muted);
}
.form__status[data-tone='error'] { color: var(--fault); }

.btn {
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: var(--step-0);
  cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.btn:hover { background: var(--bg-hover); }
.btn--primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn--primary:hover { background: color-mix(in srgb, var(--ink) 82%, var(--bg)); }
.btn--small { padding: 0.25rem 0.6rem; font-size: 0.75rem; }

.btn--fwupdate { margin-top: 0.45em; }

/*
 * The sentence under the update button.
 *
 * Reserved height is deliberate: the note appears and disappears as an update
 * moves through its phases, and without it the console header would reflow — and
 * the button move under the cursor — every time the wording changed.
 */
.console__fw-note {
  min-height: 1.2em;
  margin: 0.35em 0 0;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.link-button {
  padding: 0;
  background: none;
  border: 0;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* ------------------------------------------------------------ raw feed */
.feed {
  max-height: 18rem;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.65;
  overscroll-behavior: contain;
}
.feed li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.75rem;
  padding: 0.15rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}
.feed li:last-child { border-bottom: 0; }
.feed__time { color: var(--ink-faint); }
.feed__payload { color: var(--ink-muted); word-break: break-all; }
.feed:empty::after {
  content: 'waiting for messages…';
  color: var(--ink-faint);
}

/* ------------------------------------------------------------ empty */
.empty-state {
  padding: 3rem 0;
  max-width: 34rem;
}
.empty-state__title {
  font-size: var(--step-2);
  font-weight: 500;
  margin-bottom: 0.375rem;
}
.empty-state__body { color: var(--ink-muted); }
.empty-state code {
  padding: 0.1rem 0.3rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------ login */
.page-login { justify-content: center; }

.login {
  width: min(23rem, 100% - 2.5rem);
  margin: auto;
  padding: 3rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.login__card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.login__mark {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.login__tagline {
  font-size: var(--step-0);
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.login__form .field { max-width: none; }

.btn--block { width: 100%; padding-block: 0.55rem; }

.login__error,
.login__notice {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  font-size: var(--step-0);
  border: 1px solid;
}
.login__error {
  color: var(--fault);
  border-color: color-mix(in srgb, var(--fault) 55%, var(--line));
  background: color-mix(in srgb, var(--fault) 8%, transparent);
}
.login__notice {
  color: var(--ink-muted);
  border-color: var(--line);
}

.login__foot {
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* setup / error panels on the login card */
.alert {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.alert--error { border-color: color-mix(in srgb, var(--fault) 55%, var(--line)); }
.alert__title { font-size: var(--step-1); font-weight: 500; }
.alert--error .alert__title { color: var(--fault); }
.alert__body { font-size: var(--step-0); color: var(--ink-muted); }
.alert__pre {
  margin: 0.2rem 0;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink);
  overflow-x: auto;
}
.alert code {
  font-family: var(--font-mono);
  color: var(--ink);
  word-break: break-all;
}

/* ------------------------------------------------------------ small screens */
@media (max-width: 640px) {
  :root { --shell: calc(100% - 1.75rem); --pad: 1rem; }

  .site-header__inner { gap: 0.5rem; }
  .signout__who { display: none; }   /* the header is tight; keep the button */

  .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .location-card-grid { grid-template-columns: 1fr; }
  .stat-row  { grid-template-columns: repeat(2, 1fr); gap: 1rem 1.5rem; }
  .detail__live { align-items: flex-start; flex-direction: column; }
  .feed li { grid-template-columns: 4.5rem 1fr; gap: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
