:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --sunken: #eef0f3;
  --fg: #16181d;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --ok: #15803d;
  --bad: #b42318;
  --bad-soft: #fef3f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem 1.25rem;
}

header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--sunken);
  border-radius: 8px;
}

.segmented label { position: relative; display: block; }

.segmented input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  display: block;
  padding: .4rem .9rem;
  border-radius: 6px;
  font-size: .875rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--fg);
  font-weight: 500;
  box-shadow: var(--shadow);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.segmented.small span {
  padding: .35rem .7rem;
  font-size: .8rem;
}

.query { margin-top: 1rem; }

#target {
  display: block;
  width: 100%;
  font-size: 1rem;
  padding: .6rem .75rem;
}

.actions { margin-top: 1.25rem; }

input, select {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .4rem .55rem;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder { color: var(--faint); }

button {
  font: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .6rem 1.5rem;
  cursor: pointer;
  transition: opacity .12s ease;
}

button:hover:not(:disabled) { opacity: .9; }
button:disabled { opacity: .5; cursor: default; }

/* Stopping a run is not the same act as starting one, so it does not look it. */
button.stop { background: var(--bad); }

button.ghost {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
  font-size: .8rem;
  font-weight: 400;
  padding: .25rem .7rem;
}

button.ghost:hover:not(:disabled) {
  color: var(--fg);
  background: var(--surface);
  opacity: 1;
}

.options {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem 1.25rem;
  margin-top: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.field.grow { flex: 1 1 12rem; }
.field[hidden] { display: none; }

.label {
  font-size: .75rem;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: .01em;
}

.field input[type=number] { width: 6rem; }

.field select,
.field input:not([type=number]) { padding: .45rem .55rem; }

.from { margin-top: 1.25rem; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.chip { position: relative; }

.chip input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip span {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .875rem;
  color: var(--muted);
  cursor: pointer;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}

.chip input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chip input:disabled + span {
  color: var(--faint);
  background: var(--sunken);
  border-color: transparent;
  cursor: default;
}

.chip .offline {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.snippet {
  position: relative;
  margin-top: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sunken);
}

/* Over the command rather than above it, so the block stays two lines tall. */
.snippet #copy {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: var(--sunken);
}

.snippet pre {
  margin: 0;
  padding: .8rem 5rem .8rem .9rem;
  overflow-x: auto;
  font: 12.5px/1.6 var(--mono);
  color: #3d4149;
  white-space: pre;
}

.snippet .note {
  margin: 0;
  padding: 0 .9rem .75rem;
  color: var(--muted);
  font-size: .75rem;
}

.snippet .note[hidden] { display: none; }

#notice {
  margin-top: 1.25rem;
  padding: .7rem .9rem;
  border: 1px solid #fecdca;
  border-radius: 8px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: .875rem;
}

.result {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 1.25rem;
  overflow: hidden;
}

.result h2 {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: .9rem;
  font-weight: 600;
}

.result .status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  font-weight: 500;
  color: var(--muted);
}

.result .status.ok { color: var(--ok); }
.result .status.bad { color: var(--bad); }
.result .status.queued { color: var(--faint); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status.running .dot { animation: pulse 1.4s ease-in-out infinite; }

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

.result pre {
  margin: 0;
  padding: .9rem 1rem;
  overflow-x: auto;
  font: 12.5px/1.6 var(--mono);
  white-space: pre;
  min-height: 3rem;
  color: #23262d;
}

/* A run that goes until it is stopped prints for as long as it lasts, so its
   pane is a window on the output rather than the whole of it. */
.result pre.live {
  max-height: 60vh;
  overflow-y: auto;
}

.result pre:empty::after {
  content: "waiting for output...";
  color: var(--faint);
  font-style: italic;
}

@media (max-width: 640px) {
  header, main { padding-left: 1rem; padding-right: 1rem; }
  .actions button { width: 100%; }
  /* A command meant to be copied into a terminal is of no use on a phone. */
  .snippet { display: none; }
}
