:root {
  --bg: #0e1013;
  --bg-soft: #14171d;
  --card: #171b22;
  --line: #262c36;
  --line-soft: #1e232b;
  --text: #e9ecf1;
  --muted: #8b93a1;
  --accent: #5b8cff;
  --accent-ink: #ffffff;
  --ok: #3ecf8e;
  --bad: #ff6b6b;
  --warn: #f5b544;
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background:
    radial-gradient(1100px 520px at 50% -240px, #1b2740 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
  color: inherit;
  touch-action: manipulation;
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 15px;
  color: var(--muted);
  text-transform: lowercase;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

/* login */

.gate {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px calc(18px + env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom));
}

.gate[hidden] {
  display: none;
}

.gate-card {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
  max-width: 380px;
  padding: 28px 22px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgb(0 0 0 / 45%);
}

.gate-card h1 {
  margin-bottom: 2px;
}

/* layout */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  font-weight: 650;
  letter-spacing: -0.02em;
}

main {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 560px;
  margin: 0 auto;
  padding: 0 14px calc(28px + env(safe-area-inset-bottom));
}

.link {
  max-width: 560px;
  margin: 10px auto 0;
  padding: 0 16px;
  font-size: 13px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 16px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.foot {
  margin: 2px 0 0;
  text-align: center;
}

/* hero */

.hero {
  max-width: 560px;
  margin: 12px auto 2px;
  padding: 16px;
  text-align: center;
}

.hero[hidden] {
  display: none;
}

.hero-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-countdown {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: clamp(34px, 13vw, 46px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.hero-target {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.hero.imminent .hero-countdown {
  color: var(--accent);
}

/* fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  color: var(--muted);
  font-size: 13px;
}

.pair {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

input[type="text"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, background 0.15s;
}

textarea {
  min-height: 84px;
  line-height: 1.4;
  resize: vertical;
}

select {
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 16px top 22px, right 11px top 22px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #10141b;
}

input[type="datetime-local"] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

::placeholder {
  color: #5d6572;
}

/* buttons */

.primary {
  min-height: 52px;
  padding: 14px 18px;
  color: var(--accent-ink);
  font-weight: 600;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}

.primary:active {
  transform: scale(0.985);
  filter: brightness(0.92);
}

.primary:disabled {
  filter: grayscale(0.5) brightness(0.7);
  cursor: default;
}

.ghost {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.ghost:active {
  color: var(--text);
}

.link-button {
  align-self: flex-start;
  margin-top: -6px;
  padding: 4px 0;
  color: var(--accent);
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
}

.presets {
  display: flex;
  gap: 8px;
  margin-top: -4px;
}

.chip {
  flex: 1;
  min-height: 42px;
  padding: 9px 6px;
  color: var(--text);
  font-size: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.chip:active {
  color: var(--accent);
  border-color: var(--accent);
}

/* switch */

.switch {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-body {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  margin-top: 1px;
  background: #2a313c;
  border-radius: 999px;
  transition: background 0.18s;
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #9aa3b1;
  border-radius: 50%;
  transition: transform 0.18s, background 0.18s;
}

.switch input:checked + .switch-body {
  background: var(--accent);
}

.switch input:checked + .switch-body .switch-knob {
  background: #fff;
  transform: translateX(18px);
}

.switch-text {
  font-size: 14px;
}

.switch-text em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

/* status */

.status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.status:empty {
  display: none;
}

.status.ok {
  color: var(--ok);
}

.status.bad {
  color: var(--bad);
}

.status.warn {
  color: var(--warn);
}

.count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* jobs */

.jobs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.job {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line);
  border-radius: var(--radius-sm);
}

.job.pending,
.job.armed,
.job.firing {
  border-left-color: var(--accent);
}

.job.sent {
  border-left-color: var(--ok);
}

.job.failed,
.job.missed {
  border-left-color: var(--bad);
}

.job-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.job-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.badge {
  flex: 0 0 auto;
  padding: 3px 9px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #232a34;
  border-radius: 999px;
}

.badge.pending,
.badge.armed,
.badge.firing {
  color: var(--accent);
  background: rgb(91 140 255 / 14%);
}

.badge.sent {
  color: var(--ok);
  background: rgb(62 207 142 / 14%);
}

.badge.failed,
.badge.missed {
  color: var(--bad);
  background: rgb(255 107 107 / 14%);
}

.job-where {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 13px;
}

.job-when {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.job-note {
  color: var(--muted);
  font-size: 12.5px;
  white-space: pre-line;
}

.job-note.bad {
  color: var(--bad);
}

.job-actions {
  display: flex;
  gap: 8px;
}

.job-actions button {
  padding: 7px 12px;
  color: var(--muted);
  font-size: 13px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.job-actions button:active {
  color: var(--bad);
  border-color: var(--bad);
}

/* sessions */

.sessions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 14px;
}

.dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  background: var(--muted);
  border-radius: 50%;
  transform: translateY(-1px);
}

.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgb(62 207 142 / 15%);
}

.dot.bad {
  background: var(--bad);
  box-shadow: 0 0 0 3px rgb(255 107 107 / 15%);
}

.session-name {
  font-weight: 550;
}

.session-note {
  color: var(--muted);
  font-size: 13px;
}

@media (min-width: 520px) {
  .pair {
    flex-direction: row;
  }

  .pair .field {
    flex: 1;
    min-width: 0;
  }

  .card {
    padding: 18px;
  }
}
