:root {
  --bg: #f7f7f9;
  --surface: #ffffff;
  --text: #001924;
  --muted: #5b6670;
  --border: #dde1e6;
  --accent: #3827c8;
  --accent-text: #ffffff;
  --error: #b42318;
  --notice-bg: #fff6e0;
  --notice-border: #fdc448;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --surface: #151821;
    --text: #e8eaf0;
    --muted: #9aa3ae;
    --border: #2a2f3a;
    --accent: #8b7dff;
    --accent-text: #0b0d12;
    --error: #ff8a80;
    --notice-bg: #2b2412;
    --notice-border: #fdc448;
  }
}

* {
  box-sizing: border-box;
}

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

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

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 16px;
}

h2 {
  font-size: 1.15rem;
  margin: 28px 0 10px;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
}

.top nav a {
  text-decoration: none;
}

.top nav a:hover {
  text-decoration: underline;
}

.brand {
  font-weight: 700;
  color: var(--text);
}

.slug {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
}

.logout {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

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

table {
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  margin: 0 0 12px;
  max-width: 100%;
}

caption {
  text-align: left;
  font-weight: 600;
  padding: 0 0 6px;
}

th,
td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

thead th {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.kv th {
  font-weight: 400;
  color: var(--muted);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0 24px;
  align-items: flex-start;
}

.counts h2 {
  flex-basis: 100%;
}

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

.notice {
  padding: 8px 12px;
  background: var(--notice-bg);
  border-left: 4px solid var(--notice-border);
}

.error {
  color: var(--error);
  font-weight: 600;
}

.login {
  max-width: 360px;
  margin: 10vh auto 0;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

form label {
  display: block;
  margin: 0 0 12px;
}

input,
textarea,
select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

button {
  padding: 7px 14px;
  font: inherit;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.logout button {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 16px;
  margin: 0 0 16px;
}

.filters label {
  margin: 0;
}

.pager {
  display: flex;
  gap: 16px;
}

.copy {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Explanations: a short hint under a heading, a help box that opens with a click, and a term list. */
.hint {
  max-width: 75ch;
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 0.93rem;
}

.help {
  max-width: 75ch;
  margin: 8px 0 16px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.help summary {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.help[open] summary {
  margin-bottom: 8px;
}

.legend {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 8px 0;
}

.legend dt {
  font-weight: 600;
}

.legend dd {
  margin: 0;
  color: var(--muted);
}

/* The pipeline as a row of steps with live counts (dashboard and How it works). */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.step {
  display: grid;
  gap: 2px;
  align-content: start;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.step .count {
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.step .what {
  color: var(--muted);
  font-size: 0.85rem;
}

/* "Costs money" and "Free" badges. */
.cost {
  display: inline-block;
  justify-self: start;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.cost.paid {
  color: var(--text);
  background: var(--notice-bg);
  border-color: var(--notice-border);
}

/* One step on the How it works page. */
.guide-step {
  max-width: 80ch;
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.guide-step h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-top: 0;
}

.guide-step ul {
  margin: 6px 0;
  padding-left: 1.2em;
}

/* The Settings page: one section per form, offers and targets as rows that open, and the list of places. */
.settings {
  max-width: 80ch;
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.settings h2,
.instructions h2 {
  margin-top: 0;
}

.settings fieldset,
.instructions fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

details.item {
  margin: 0 0 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

details.item summary {
  cursor: pointer;
}

details.item[open] summary {
  margin-bottom: 10px;
}

.badge {
  display: inline-block;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.badge.on {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

form label.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

label.check input {
  display: inline;
  width: auto;
  margin: 0;
}

ol.places {
  padding-left: 2.4em;
}

ol.places form {
  margin: 0;
}

ol.places fieldset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}

/* A quiet button, for one row of a long list (Remove on each place). */
button.small {
  padding: 2px 10px;
  color: var(--accent);
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid var(--border);
}

.saved {
  padding: 8px 12px;
  background: var(--bg);
  border-left: 4px solid var(--accent);
}

/* The Instructions page: one section per kind, a large monospace editor, and the text Claude gets, read-only. */
.instructions {
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.instructions h3 {
  margin: 20px 0 8px;
  font-size: 1rem;
}

/* At least 30 lines high, whatever the rows attribute says. */
.editor {
  width: 100%;
  min-height: calc(30 * 1.5em + 16px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  resize: vertical;
}

.instructions form.reset {
  margin-top: 16px;
}

pre.preview {
  max-height: 32em;
  overflow: auto;
  margin: 0 0 12px;
  padding: 8px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

table.versions td.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

table.versions form {
  margin: 0;
}

/* The Control page: whether the worker runs, and one card per switch with its steps' last results. */
.status {
  padding: 8px 12px;
  background: var(--surface);
  border-left: 4px solid var(--accent);
}

.switch {
  max-width: 80ch;
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.switch h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-top: 0;
}

.results {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 12px 0 0;
}

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

.results dd {
  margin: 0;
}

/* The Mailboxes page: each mailbox as a row that opens, its buttons in a row, the warm-up fields together, and a
   danger button for Remove. */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.actions form {
  margin: 0;
}

.settings fieldset.warmup {
  margin: 0 0 12px;
  padding: 8px 12px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
}

fieldset.warmup legend {
  padding: 0 4px;
  color: var(--muted);
}

form.remove {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

button.danger {
  color: var(--surface);
  background: var(--error);
}

ul.removed {
  padding-left: 1.2em;
}

ul.removed li {
  margin: 0 0 8px;
}

@media (max-width: 640px) {
  table {
    display: block;
    overflow-x: auto;
  }

  .legend,
  .results {
    grid-template-columns: 1fr;
  }
}
