/* URLWatch — an instrument panel, not a dashboard.
   Chassis is cool graphite; the only saturated colour on screen is a signal. */

:root {
  --panel: #10151c;
  --panel-2: #171e27;
  --panel-3: #1d2631;
  --rule: #26313e;
  --rule-soft: #1c242e;

  --ink: #e6edf3;
  --ink-mid: #9aa8b6;
  --ink-dim: #6b7885;

  --up: #4ec9a0;
  --warn: #e0a45c;
  --down: #e0616a;
  --never: #55636f;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 940px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--panel);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--up);
}

/* ---------------------------------------------------------------- shell -- */

.shell {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 34px 0 18px;
}

.wordmark {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

.wordmark .dot {
  color: var(--up);
}

/* ------------------------------------------------------- staleness rule -- */

.freshness {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 12.5px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.freshness-track {
  position: relative;
  flex: 1 1 120px;
  max-width: 220px;
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}

.freshness-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--ink-dim);
  transition: width 0.4s ease, background-color 0.4s ease;
}

.freshness-fill[data-age="fresh"] {
  background: var(--up);
}

.freshness-fill[data-age="stale"] {
  background: var(--warn);
}

.freshness-fill[data-age="rotten"] {
  background: var(--down);
}

/* ------------------------------------------------------------- toolbar -- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.count {
  font-size: 12.5px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- board -- */

.board {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px 92px 96px;
  align-items: center;
  gap: 0 16px;
  padding: 13px 0 13px 14px;
  border-bottom: 1px solid var(--rule-soft);
  border-left: 3px solid var(--never);
  position: relative;
}

.row[data-state="up"] {
  border-left-color: var(--up);
}

.row[data-state="warn"] {
  border-left-color: var(--warn);
}

.row[data-state="down"] {
  border-left-color: var(--down);
}

.row.is-busy {
  opacity: 0.5;
}

.cell-id {
  min-width: 0;
}

.name {
  display: block;
  font-weight: 500;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.target:hover {
  color: var(--ink-mid);
  text-decoration: underline;
}

.fault {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--down);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-status,
.cell-ms,
.cell-when {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-mid);
  font-variant-numeric: tabular-nums;
}

.cell-ms,
.cell-when {
  text-align: right;
  color: var(--ink-dim);
}

/* the pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 7px;
  border: 1px solid currentColor;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: currentColor;
  flex: none;
}

.pill[data-state="up"] {
  color: var(--up);
}

.pill[data-state="warn"] {
  color: var(--warn);
}

.pill[data-state="down"] {
  color: var(--down);
}

.pill[data-state="never"] {
  color: var(--never);
  border-style: dashed;
}

/* row actions, revealed on hover/focus but always reachable by keyboard */
.row-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.row-actions[hidden] {
  display: none;
}

/* -------------------------------------------------------------- forms --- */

.linkbtn {
  background: none;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink-dim);
  font: inherit;
  font-size: 12px;
  padding: 3px 9px;
  cursor: pointer;
}

.linkbtn:hover {
  color: var(--ink);
  border-color: var(--ink-dim);
}

.linkbtn.danger:hover {
  color: var(--down);
  border-color: var(--down);
}

.composer {
  padding: 26px 0 40px;
}

.composer h2 {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-mid);
  margin: 0 0 12px;
}

.field-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  padding: 9px 11px;
  min-width: 0;
}

input[type="text"]::placeholder {
  color: var(--never);
}

#watch-name,
#name {
  flex: 0 1 200px;
}

#watch-url,
#url {
  flex: 1 1 260px;
  font-family: var(--mono);
  font-size: 13px;
}

button.primary {
  background: var(--panel-3);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

button.primary:hover:not(:disabled) {
  border-color: var(--ink-dim);
}

button.primary:disabled {
  opacity: 0.55;
  cursor: progress;
}

:focus-visible {
  outline: 2px solid var(--up);
  outline-offset: 2px;
}

.notice {
  font-size: 12.5px;
  color: var(--warn);
  margin: 10px 0 0;
  min-height: 18px;
}

.notice[data-tone="bad"] {
  color: var(--down);
}

.notice[data-tone="good"] {
  color: var(--up);
}

/* ------------------------------------------------------------ spinner --- */

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--rule);
  border-top-color: var(--up);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
  .freshness-fill {
    transition: none;
  }
}

/* -------------------------------------------------------------- empty --- */

.empty {
  padding: 44px 0;
  border-bottom: 1px solid var(--rule-soft);
  color: var(--ink-dim);
  font-size: 14px;
}

.empty strong {
  color: var(--ink-mid);
  font-weight: 500;
}

/* -------------------------------------------------------------- auth ---- */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
}

.gate-card {
  width: 100%;
  max-width: 380px;
}

.gate-card h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.gate-card p {
  color: var(--ink-dim);
  font-size: 13.5px;
  margin: 0 0 24px;
}

.gate-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gate-card input {
  width: 100%;
}

.gate-card button.primary {
  justify-content: center;
  margin-top: 4px;
}


@media (max-width: 640px) {
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 6px;
  }
  .cell-ms,
  .cell-when {
    text-align: left;
  }
  .cell-status {
    justify-self: end;
  }
  .row-actions {
    grid-column: 1 / -1;
  }
}
