/* Reset and base typography */

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

html, body { margin: 0; padding: 0; }

html {
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-3);
  line-height: var(--lh);
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  line-height: 1.25;
}
h1 { font-size: var(--fs-4); }
h2 { font-size: var(--fs-3); }
h3 { font-size: var(--fs-2); color: var(--text-muted); font-weight: 600; }

p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dt, dd { margin: 0; }
table { border-collapse: collapse; border-spacing: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }

[hidden] { display: none !important; }

/* Numeric readouts: monospaced with tabular figures so digits do not jitter. */
.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.small { font-size: var(--fs-1); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Focus: a visible 2px ring on every focusable control. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  height: var(--control-h);
  padding: 0 var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  font-size: var(--fs-2);
  font-weight: 500;
}
.btn:hover { background: var(--bg-3); }
.btn:active { background: var(--bg-1); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn--primary {
  background: var(--nominal);
  border-color: var(--nominal);
  color: #061019;
}
.btn--primary:hover { background: #6cc7f7; }
.btn--danger {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}
.btn--danger:hover { background: var(--danger-dim); }
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn--ghost:hover { background: var(--bg-2); color: var(--text); }
.btn--sm {
  height: 24px;
  padding: 0 var(--s-2);
  font-size: var(--fs-1);
}
.btn--icon {
  width: var(--control-h);
  padding: 0;
  justify-content: center;
}

/* Inputs */
.input, .select {
  height: var(--control-h);
  padding: 0 var(--s-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-3);
  color: var(--text);
  font-size: var(--fs-2);
  min-width: 0;
}
.input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.input:invalid { border-color: var(--danger); }
.select { padding-right: var(--s-4); }
.input--sm { height: 24px; font-size: var(--fs-1); }

input[type="range"] { width: 100%; accent-color: var(--nominal); }
input[type="checkbox"] { accent-color: var(--nominal); width: 16px; height: 16px; }

/* Value update flash: brief, explains that a number changed. */
@keyframes sems-flash {
  from { background: var(--anomaly-dim); }
  to { background: transparent; }
}
.flash { animation: sems-flash 600ms ease-out; }

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