/* MonitorBot dashboard styles.
 *
 * Visual language: monochrome, dot-matrix display type, uppercase mono labels,
 * pill controls, and a single red accent that always means "look here".
 * State is carried by fill (outline / inverted / red), never by hue alone.
 *
 * Motion rules this file follows:
 *   - every transition names its exact properties, never `all`
 *   - UI transitions stay under 300ms, exits are faster than enters
 *   - custom ease-out curves; `ease-in` is never used
 *   - hover effects are gated behind a real pointer
 *   - depth comes from box-shadow, structure from borders
 */

/* Self-hosted so the dashboard has no third-party requests. All three are
   SIL Open Font License. Doto stands in for a proprietary dot-matrix face. */
@font-face {
  font-family: "Doto";
  src: url("/static/fonts/Doto-100_900.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/SpaceGrotesk-300_700.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Space Mono";
  src: url("/static/fonts/SpaceMono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Space Mono";
  src: url("/static/fonts/SpaceMono-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --bg: #000000;
  --surface: #0b0b0b;
  --surface-2: #141414;
  --surface-3: #1e1e1e;
  --divider: #232323;
  --text: #ffffff;
  --muted: #8c8c8c;
  --faint: #5a5a5a;
  --red: #d71921;

  --font-display: "Doto", "Space Mono", ui-monospace, monospace;
  --font-label: "Space Mono", ui-monospace, Consolas, monospace;
  --font-body: "Space Grotesk", "Segoe UI", system-ui, sans-serif;

  /* Dark mode: a single white ring reads as a border; layered depth shadows
     are invisible on a dark background. */
  --shadow-border: 0 0 0 1px oklch(1 0 0 / 0.1);
  --shadow-border-hover: 0 0 0 1px oklch(1 0 0 / 0.22);
  --shadow-raised: 0 0 0 1px oklch(1 0 0 / 0.22), 0 16px 40px -16px oklch(0 0 0 / 0.9);
  --shadow-overlay: 0 0 0 1px oklch(1 0 0 / 0.14), 0 24px 64px -20px oklch(0 0 0 / 0.95);

  /* Neutral outline for anything image-like. Pure white at low opacity, never
     a tinted near-white, which would read as dirt on the edge. */
  --image-outline: oklch(1 0 0 / 0.1);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-cross: cubic-bezier(0.2, 0, 0, 1);

  /* Concentric: an inner radius plus the inset that surrounds it. */
  --r-card: 20px;
  --r-inset: 10px; /* 20 - 10px badge inset */
  --r-screen: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font: 14px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg);
  /* The dot grid: faint enough to disappear behind content. */
  background-image: radial-gradient(#1c1c1c 1px, transparent 1px);
  background-size: 18px 18px;
  background-attachment: fixed;
}

button, select, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Live numbers change every second; proportional digits make the row jitter. */
.tnum { font-variant-numeric: tabular-nums; }

/* An <svg> with no width/height falls back to 300x150. Take it out of flow and
   collapse it so the icon definitions cost no layout. */
.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* --------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 0;
  border-radius: 999px;
  box-shadow: var(--shadow-border);
  color: var(--text);
  font: 400 11.5px/1 var(--font-label);
  letter-spacing: 0.9px;
  text-transform: uppercase;
  padding: 11px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition-property: background-color, box-shadow, color, scale, opacity;
  transition-duration: 150ms;
  transition-timing-function: var(--ease-out);
}

/* A leading icon makes symmetric padding look right-heavy. */
.btn:has(svg:first-child), .btn:has(.icon-stack:first-child) { padding-inline-start: 14px; }
.btn.icon-only { padding: 9px; gap: 0; }

.btn svg { flex: none; }

.btn:active:not(:disabled) { scale: 0.96; }

.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn.primary {
  background: var(--text);
  color: #000;
  font-weight: 700;
  box-shadow: none;
}

.btn.danger { color: var(--red); box-shadow: 0 0 0 1px oklch(0.55 0.22 27 / 0.5); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }

/* Driving a remote machine is the one thing that should never be ambient. */
.btn.on {
  background: var(--red);
  color: #fff;
  box-shadow: none;
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: var(--surface-2); box-shadow: var(--shadow-border-hover); }
  .btn.primary:hover:not(:disabled) { background: #d9d9d9; }
  .btn.danger:hover:not(:disabled) { background: var(--red); color: #fff; box-shadow: none; }
  .btn.ghost:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }
  .btn.on:hover:not(:disabled) { background: #ef2a33; box-shadow: none; }
}

.select-wrap { position: relative; display: inline-flex; align-items: center; }
.select-wrap svg { position: absolute; left: 14px; pointer-events: none; color: var(--muted); }
.select-wrap select { padding-inline-start: 38px; appearance: none; padding-inline-end: 34px; }
.select-wrap select option { font-family: var(--font-body); text-transform: none; letter-spacing: 0; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  rotate: 45deg;
  translate: 0 -2px;
  pointer-events: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  box-shadow: var(--shadow-border);
  border-radius: 999px;
  padding: 6px 13px;
  color: var(--muted);
  font: 400 10.5px/1 var(--font-label);
  letter-spacing: 0.9px;
  text-transform: uppercase;
  white-space: nowrap;
  transition-property: color, box-shadow;
  transition-duration: 150ms;
  transition-timing-function: var(--ease-out);
}

.pill b {
  color: var(--text);
  font: 800 16px/1 var(--font-display);
  letter-spacing: 0;
}

.pill.alert { color: var(--red); box-shadow: 0 0 0 1px oklch(0.55 0.22 27 / 0.6); }
.pill.alert b { color: var(--red); }

/* Inline state chip used wherever a status is named in running text. */
.state { font-weight: 700; color: var(--text); }
.state.stuck { background: var(--text); color: #000; padding: 2px 6px; border-radius: 4px; }
.state.dead, .state.offline { background: var(--red); color: #fff; padding: 2px 6px; border-radius: 4px; }

/* Cross-fade two icons in place: the entering one scales up from 0.25 while
   the leaving one scales down, both with blur. Nothing unmounts, so the swap
   animates in both directions. */
.icon-stack { position: relative; width: 16px; height: 16px; flex: none; }
.icon-stack .ic {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition-property: opacity, filter, scale;
  transition-duration: 300ms;
  transition-timing-function: var(--ease-cross);
}
.icon-stack .ic-on  { scale: 0.25; opacity: 0; filter: blur(4px); }
.icon-stack .ic-off { scale: 1;    opacity: 1; filter: blur(0px); }
[aria-pressed="true"] .icon-stack .ic-on  { scale: 1;    opacity: 1; filter: blur(0px); }
[aria-pressed="true"] .icon-stack .ic-off { scale: 0.25; opacity: 0; filter: blur(4px); }

/* ----------------------------------------------------------------- header */

header.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: oklch(0 0 0 / 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--divider); /* structural divider stays a border */
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-inline-end: 8px;
}

.brand .wordmark {
  font: 900 22px/1 var(--font-display);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 400 9.5px/1 var(--font-label);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--red);
  transition-property: color;
  transition-duration: 200ms;
  transition-timing-function: var(--ease-out);
}

.link .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.1s var(--ease-in-out) infinite; /* urgent while disconnected */
}

.link.live { color: var(--muted); }
.link.live .dot { background: var(--text); animation: none; }

.stats { display: flex; gap: 8px; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------- grid */

main {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

main.dense { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
main.wide  { grid-template-columns: repeat(auto-fill, minmax(540px, 1fr)); }

.card {
  background: var(--surface);
  border: 0;
  border-radius: var(--r-card);
  box-shadow: var(--shadow-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition-property: box-shadow, translate;
  transition-duration: 180ms;
  transition-timing-function: var(--ease-out);
}

.card.stuck { box-shadow: 0 0 0 1px oklch(1 0 0 / 0.7); }
.card.dead  { box-shadow: 0 0 0 1px var(--red); }

@media (hover: hover) and (pointer: fine) {
  .card:hover { box-shadow: var(--shadow-raised); translate: 0 -2px; }
  .card.stuck:hover { box-shadow: 0 0 0 1px #fff, 0 16px 40px -16px oklch(0 0 0 / 0.9); }
  .card.dead:hover  { box-shadow: 0 0 0 1px var(--red), 0 16px 40px -16px oklch(0 0 0 / 0.9); }
}

.card .screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card .screen canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  /* Neutral hairline so a dark frame still reads as a distinct surface. */
  outline: 1px solid var(--image-outline);
  outline-offset: -1px;
}

.card .screen .placeholder {
  color: var(--faint);
  font: 400 10px/1 var(--font-label);
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-inset); /* concentric with the 20px card corner */
  font: 700 10px/1 var(--font-label);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  background: oklch(0 0 0 / 0.72);
  backdrop-filter: blur(6px);
  color: var(--text);
}

/* Four states told apart by fill, so they survive a monochrome palette. */
.badge.stuck { background: var(--text); color: #000; backdrop-filter: none; }
.badge.dead { background: var(--red); color: #fff; backdrop-filter: none; }
.badge.offline { color: var(--muted); box-shadow: inset 0 0 0 1px var(--faint); }

.badge .blink {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge.offline .blink { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }

/* Only a healthy stream pulses; the label carries the state on its own, so the
   motion is a second channel, never the only one. */
.badge.live .blink { animation: pulse 2.4s var(--ease-in-out) infinite; }

@keyframes pulse { 50% { opacity: 0.25; } }

.card .meta {
  padding: 13px 16px 15px;
  border-top: 1px solid var(--divider);
  display: grid;
  gap: 4px;
}

.card .meta .row { display: flex; align-items: baseline; gap: 10px; }

.card .meta .title {
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.card .meta .res {
  color: var(--faint);
  font: 400 10px/1 var(--font-label);
  letter-spacing: 0.6px;
  flex: none;
}

.card .meta .machine {
  color: var(--muted);
  font: 400 10.5px/1.3 var(--font-label);
  letter-spacing: 0.9px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metrics { display: flex; gap: 18px; margin-top: 10px; }
.metric { flex: 1; min-width: 0; }

.metric .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.metric .head .k {
  font: 400 9.5px/1 var(--font-label);
  letter-spacing: 1.2px;
  color: var(--faint);
}

.metric .head .v {
  font: 800 17px/1 var(--font-display);
  color: var(--text);
  transition-property: color;
  transition-duration: 200ms;
  transition-timing-function: var(--ease-out);
}

.metric:has(.bar.crit) .head .v { color: var(--red); }

/* The mask cuts the track into dot-matrix segments. It lives on the track, so
   the fill can still scale underneath it on the GPU without moving the dots. */
.bar {
  display: block;
  height: 5px;
  background: #222;
  overflow: hidden;
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 6px);
  mask-image: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 6px);
}

.bar i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
  background: var(--text);
  /* scaleX composites on the GPU; animating width would relayout every tick. */
  transition-property: transform, background-color;
  transition-duration: 260ms;
  transition-timing-function: var(--ease-out);
}

.bar.crit i { background: var(--red); }

/* Cards animate in only on the first paint, where the sequence reads as the
   dashboard filling up. Later arrivals fade in with no stagger. */
.card.enter {
  opacity: 0;
  translate: 0 10px;
  filter: blur(4px);
  animation: cardIn 380ms var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 55ms);
}

@keyframes cardIn {
  to { opacity: 1; translate: 0 0; filter: blur(0); }
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 110px 20px;
  color: var(--muted);
}

.empty h2 {
  color: var(--text);
  font: 900 34px/1.1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 14px;
}

.empty p {
  margin: 0 auto;
  max-width: 420px;
  font: 400 11px/1.7 var(--font-label);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.stagger-item {
  opacity: 0;
  translate: 0 12px;
  filter: blur(4px);
  animation: cardIn 400ms var(--ease-out) forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 100ms; }
.stagger-item:nth-child(3) { animation-delay: 200ms; }

/* ------------------------------------------------------------------ stage */

#stage {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  background: oklch(0 0 0 / 0.8);
  backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* Exit is quicker than enter: attention is already moving elsewhere. */
  transition-property: opacity, visibility;
  transition-duration: 160ms, 0s;
  transition-delay: 0s, 160ms;
  transition-timing-function: var(--ease-out);
}

#stage.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-duration: 220ms, 0s;
  transition-delay: 0s, 0s;
}

.stage-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* A modal is not anchored to a trigger, so it scales from its own centre. */
  transform-origin: center;
  scale: 0.97;
  opacity: 0;
  transition-property: scale, opacity;
  transition-duration: 160ms;
  transition-timing-function: var(--ease-out);
}

#stage.open .stage-shell {
  scale: 1;
  opacity: 1;
  transition-duration: 220ms;
}

.bar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--divider);
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

/* The ring of a pill is drawn outside its box; give the scroller room for it. */
.bar-top > * { margin-block: 1px; }

.bar-top > .stage-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
  font: 700 12px/1 var(--font-label);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.bar-top .btn, .bar-top .pill, .bar-top .select-wrap, .bar-top .sep { flex-shrink: 0; }

.sep { width: 1px; align-self: stretch; background: var(--divider); margin-inline: 4px; }

.stage-body { flex: 1; display: flex; min-height: 0; }

#stageWrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 16px;
  min-width: 0;
}

#stageCanvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r-screen);
  background: #000;
  outline: 1px solid var(--image-outline);
  outline-offset: -1px;
  transition-property: box-shadow;
  transition-duration: 150ms;
  transition-timing-function: var(--ease-out);
}

#stageCanvas.controlling {
  box-shadow: 0 0 0 2px var(--red), 0 0 36px -6px oklch(0.55 0.22 27 / 0.7);
  cursor: crosshair;
}

#logPanel {
  width: 340px;
  border-left: 1px solid var(--divider);
  background: var(--bg);
  padding: 12px 14px;
  overflow-y: auto;
  font: 400 11px/1.5 var(--font-label);
  color: #b4b4b4;
  white-space: pre-wrap;
  word-break: break-word;
}

#logPanel[hidden] { display: none; }
#logPanel div { padding: 3px 0; border-bottom: 1px dotted #262626; }

#logPanel.enter {
  animation: panelIn 200ms var(--ease-out) forwards;
}

@keyframes panelIn {
  from { opacity: 0; translate: 8px 0; }
  to { opacity: 1; translate: 0 0; }
}

/* ---------------------------------------------------------------- popover */

/* Anchored to its trigger, so it grows out of the trigger's corner rather than
   from its own centre. */
.popover {
  position: fixed;
  z-index: 60;
  width: 264px;
  padding: 16px;
  background: var(--surface);
  border-radius: 28px; /* concentric: 12px field + 16px padding */
  box-shadow: var(--shadow-overlay);
  transform-origin: top right;
  scale: 0.96;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition-property: scale, opacity, visibility;
  transition-duration: 120ms, 120ms, 0s;
  transition-delay: 0s, 0s, 120ms;
  transition-timing-function: var(--ease-out);
}

.popover.open {
  scale: 1;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-duration: 180ms, 180ms, 0s;
  transition-delay: 0s;
}

.pop-title {
  font: 700 11px/1.3 var(--font-label);
  letter-spacing: 1.1px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.pop-title span { color: var(--muted); }

.popover label {
  display: block;
  font: 400 9.5px/1 var(--font-label);
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.pop-field { position: relative; }

.pop-field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid #2c2c2c;
  border-radius: 12px;
  padding: 10px 54px 10px 14px;
  font: 800 30px/1 var(--font-display);
  appearance: textfield;
  -moz-appearance: textfield;
  transition-property: border-color, box-shadow;
  transition-duration: 150ms;
  transition-timing-function: var(--ease-out);
}

.pop-field input::-webkit-outer-spin-button,
.pop-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.pop-field input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px oklch(1 0 0 / 0.12);
}

.pop-field input:invalid { border-color: var(--red); }

.pop-field .unit {
  position: absolute;
  right: 14px;
  top: 50%;
  translate: 0 -50%;
  font: 400 10px/1 var(--font-label);
  letter-spacing: 1.2px;
  color: var(--faint);
  pointer-events: none;
}

.chips { display: flex; gap: 6px; margin: 10px 0 16px; }

.chip {
  flex: 1;
  background: var(--bg);
  border: 0;
  border-radius: 999px;
  box-shadow: var(--shadow-border);
  padding: 8px 0;
  font: 400 11px/1 var(--font-label);
  letter-spacing: 0.6px;
  color: var(--muted);
  cursor: pointer;
  transition-property: background-color, box-shadow, color, scale;
  transition-duration: 150ms;
  transition-timing-function: var(--ease-out);
}

.chip:active { scale: 0.96; }
.chip.picked { background: var(--text); color: #000; box-shadow: none; }

@media (hover: hover) and (pointer: fine) {
  .chip:hover:not(.picked) { color: var(--text); box-shadow: var(--shadow-border-hover); }
}

.popover .btn { width: 100%; justify-content: center; padding-block: 13px; }

.countdown {
  font: 900 44px/1 var(--font-display);
  color: var(--red);
  text-align: center;
  margin: 4px 0 12px;
}

.pop-note {
  margin: 0 0 16px;
  color: var(--muted);
  font: 400 10px/1.6 var(--font-label);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  text-align: center;
}

/* Countdown on the tile, so a pending shutdown is visible without opening it. */
.power-chip {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-inset);
  background: var(--red);
  color: #fff;
  font: 700 10px/1 var(--font-label);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.power-chip[hidden] { display: none; }

/* ----------------------------------------------------------------- toasts */

#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  position: relative;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-overlay);
  padding: 12px 16px 12px 30px;
  max-width: 380px;
  font-size: 13px;
  animation: toastIn 220ms var(--ease-out);
}

/* A status dot instead of a stripe; its fill is the level. */
.toast::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 17px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text);
}

.toast.warn::before, .toast.bad::before { background: var(--red); }

/* Leaves the way it arrived, so the motion reads as one object. */
.toast.leaving {
  opacity: 0;
  translate: 12px 0;
  transition-property: opacity, translate;
  transition-duration: 150ms;
  transition-timing-function: var(--ease-out);
}

@keyframes toastIn {
  from { opacity: 0; translate: 18px 0; }
  to { opacity: 1; translate: 0 0; }
}

/* ------------------------------------------------------------------ login */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  border-radius: 28px;
  padding: 36px 32px 30px;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  margin: 0 0 10px;
  font: 900 38px/1 var(--font-display);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.login-card p.sub {
  margin: 0 0 28px;
  color: var(--muted);
  font: 400 10.5px/1.5 var(--font-label);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.login-card label {
  display: block;
  font: 400 9.5px/1 var(--font-label);
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.login-card input {
  width: 100%;
  background: var(--bg);
  /* Inputs keep a real border: the outline is the affordance. */
  border: 1px solid #2c2c2c;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 15px;
  transition-property: border-color, box-shadow;
  transition-duration: 150ms;
  transition-timing-function: var(--ease-out);
}

.login-card input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px oklch(1 0 0 / 0.12);
}

.login-card .btn { width: 100%; justify-content: center; padding-block: 15px; margin-top: 4px; }

.login-card .error {
  color: var(--red);
  font: 400 10.5px/1.4 var(--font-label);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  min-height: 18px;
  margin-top: 14px;
  opacity: 0;
  transition-property: opacity;
  transition-duration: 150ms;
  transition-timing-function: var(--ease-out);
}

.login-card .error.show { opacity: 1; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 760px) {
  #logPanel { display: none; }
  main { padding: 12px; gap: 12px; }
  header.top { gap: 8px; padding: 10px 12px; }
  .link span:last-child { display: none; }
  .stats .pill:nth-child(-n + 2) { display: none; }
}

/* Fewer and gentler, not none: colour and opacity still carry meaning, and
   only the movement goes away. */
@media (prefers-reduced-motion: reduce) {
  .card.enter, .stagger-item, #logPanel.enter {
    animation-name: fadeOnly;
    animation-duration: 200ms;
    animation-delay: 0ms !important;
  }
  .badge.live .blink, .link .dot { animation: none; }
  .card:hover { translate: none; }
  .btn:active:not(:disabled) { scale: 1; }
  .stage-shell, .popover { scale: 1; }
  .chip:active { scale: 1; }
  .toast { animation-name: fadeOnly; }
  .toast.leaving { translate: none; }
  .icon-stack .ic { transition-property: opacity; }
}

@keyframes fadeOnly {
  from { opacity: 0; filter: blur(2px); }
  to { opacity: 1; filter: blur(0); }
}
