/* Build: Wisdom Pools' palette and type, so the two apps feel like one family. */

:root {
  --bg: #f4f7f3;
  --surface: #ffffff;
  --ink: #24332e;
  --ink-soft: #5b6d66;
  --line: #e0e8e1;
  --accent: #3f7d6b;
  --accent-text: #2f6656;
  --accent-soft: #e2efe8;
  --accent-ink: #ffffff;
  --ok: #2f7a50;
  --warn: #9a6a1f;
  --danger: #a3473a;
  --danger-soft: #f7e6e2;
  --stream: #a9cbbd;

  --serif: "Fraunces", Georgia, serif;
  --sans: "Atkinson Hyperlegible", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.625rem;
  --step-3: 2.125rem;

  --gutter: 16px;
  --radius-field: 12px;
  --radius-button: 999px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111a17;
    --surface: #18241f;
    --ink: #e6efea;
    --ink-soft: #9fb2aa;
    --line: #2a3a33;
    --accent: #7cc2aa;
    --accent-text: #9ad4bf;
    --accent-soft: #1f3a31;
    --accent-ink: #10231c;
    --ok: #7fcb98;
    --warn: #e2b46a;
    --danger: #ec9686;
    --danger-soft: #3a211d;
    --stream: #2f5a4b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--step-0)/1.5 var(--sans);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) var(--gutter) max(32px, env(safe-area-inset-bottom));
}

h1, h2, .prompt {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

h1 { font-size: var(--step-3); line-height: 1.1; }
h2 { font-size: var(--step-1); line-height: 1.25; margin: 40px 0 12px; }

p { margin: 0 0 12px; }

a { color: var(--accent-text); text-underline-offset: 3px; }

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

.muted { color: var(--ink-soft); }
.small { font-size: var(--step--1); }

/* ---- Header ---- */

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.top .who { font-size: var(--step--1); color: var(--ink-soft); text-align: right; }

.link-button {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--accent-text);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---- Forms ---- */

label { display: block; font-weight: 700; margin: 0 0 6px; }

.ask-label {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--step-2);
  line-height: 1.2;
  margin-bottom: 12px;
}

textarea, input, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  padding: 12px 14px;
}

textarea {
  min-height: 9.5em;
  resize: vertical;
  font-family: var(--serif);
  font-size: var(--step-1);
  line-height: 1.45;
}

textarea:focus, input:focus, select:focus { border-color: var(--accent); outline: none; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
  margin: 16px 0 20px;
}

.fields .wide { grid-column: 1 / -1; }

.hint { font-size: var(--step--1); color: var(--ink-soft); margin-top: 6px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--radius-button);
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 var(--step-0)/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
}

.button.full { width: 100%; }
.button:disabled { opacity: 0.55; cursor: default; }

.button.quiet {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid currentColor;
}

.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-field);
  padding: 12px 14px;
  margin: 0 0 16px;
}

/* ---- Sign in ---- */

.signin { padding-top: 12vh; }
.signin h1 { margin-bottom: 12px; }
.signin p { color: var(--ink-soft); margin-bottom: 28px; max-width: 34ch; }
.signin form { display: grid; gap: 14px; }

/* ---- Job list ---- */

.jobs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }

.jobs a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.jobs .what {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.jobs .when { font-size: var(--step--1); color: var(--ink-soft); white-space: nowrap; }
.jobs .meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status.working { color: var(--accent-text); }
.status.working::before { animation: pulse 1.6s ease-in-out infinite; }
.status.ready { color: var(--ok); }
.status.none { color: var(--ink-soft); }
.status.failed { color: var(--danger); }
.status.waiting { color: var(--warn); }

.empty { color: var(--ink-soft); padding: 16px 0; }

/* ---- Job page ---- */

.back { display: inline-block; margin-bottom: 20px; }

.prompt {
  font-size: var(--step-2);
  line-height: 1.25;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-bottom: 10px;
}

.facts { color: var(--ink-soft); font-size: var(--step--1); margin-bottom: 20px; }

.outcome {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-field) var(--radius-field) 0;
  padding: 16px 18px;
  margin: 0 0 8px;
}

.outcome.failed { border-color: var(--danger); background: var(--danger-soft); }
.outcome.none { border-color: var(--line); background: var(--surface); }
.outcome .status { margin-bottom: 8px; }
.outcome .button { margin-top: 8px; }

.summary p:last-child, .summary ul:last-child { margin-bottom: 0; }
.summary ul { margin: 0 0 12px; padding-left: 1.2em; }
.summary code, .step code { font-family: var(--mono); font-size: 0.88em; overflow-wrap: anywhere; }

.files { font-size: var(--step--1); color: var(--ink-soft); margin-top: 10px; overflow-wrap: anywhere; }

/* The stream: each step is a point on a line that flows down the page. */
.stream { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.stream::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 2px;
  background: var(--stream);
}
.stream.live::before {
  background: linear-gradient(to bottom, var(--stream) 0%, var(--stream) 80%, var(--accent) 100%);
}

.step { position: relative; padding: 6px 0 10px; overflow-wrap: anywhere; }
.step::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 0.85em;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.step.say::before { background: var(--accent); }
.step.err::before { border-color: var(--danger); background: var(--danger); }
.step .verb { font-weight: 700; }
.step .detail { font-family: var(--mono); font-size: 0.88em; color: var(--ink-soft); }
.step.say { white-space: pre-wrap; }
.step.err { color: var(--danger); }

.step.now { color: var(--ink-soft); }
.step.now::before { border-color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }

.actions { margin-top: 28px; }

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

@media (prefers-reduced-motion: reduce) {
  .status.working::before, .step.now::before { animation: none; }
}
