:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1d21;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2f6feb;
  --agent: #7c3aed;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --panel: #1f2229;
    --ink: #e8eaed;
    --muted: #99a0ad;
    --line: #2e323b;
    --accent: #6a9bff;
    --agent: #b18aff;
  }
}

* { box-sizing: border-box; }

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

main { padding: 20px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand { font-weight: 650; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.actor { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.error { color: #d33; font-size: 13px; }

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

.toolbar { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; }

.filters { display: flex; gap: 6px; }
.filters a {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
}
.filters a.active { color: var(--panel); background: var(--accent); border-color: var(--accent); }

details.new > summary {
  cursor: pointer;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
  list-style: none;
}
details.new[open] > summary { border-color: var(--accent); }

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

details.new .card { position: absolute; z-index: 5; margin-top: 8px; min-width: 280px; }

input, textarea, select, button {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { resize: vertical; }
button { background: var(--accent); color: #fff; border-color: transparent; cursor: pointer; font-weight: 550; }
button:hover { filter: brightness(1.08); }

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}

.column {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.column h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 2px 4px 10px;
  display: flex;
  gap: 6px;
}
.column .count { color: var(--line); }

.dropzone { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }

.task {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  cursor: grab;
}
.task.dragging { opacity: 0.4; }
.task-link { text-decoration: none; color: var(--ink); display: flex; gap: 8px; flex: 1; align-items: baseline; }
.key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }
.badge {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px;
}
.badge.assignee { color: var(--accent); border-color: var(--accent); }

.task-page { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.task-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.task-head h1 { font-size: 20px; margin: 0; flex: 1; }
.task-head .back { text-decoration: none; font-size: 13px; }
.task-head .assigned, .task-head .filed { font-size: 13px; color: var(--muted); }

.thread { display: flex; flex-direction: column; gap: 10px; }
.message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.message .meta { display: flex; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.message .who { font-weight: 600; color: var(--ink); }
.message.actor-foreman { border-left-color: var(--agent); }

/* Task bodies and messages, once markdown has been rendered. */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md table { margin: 0 0 8px; }
.md h3, .md h4, .md h5, .md h6 { margin: 14px 0 6px; font-size: 15px; }
.md h3 { font-size: 16px; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 2px 0; }
.md li input { margin: 0 6px 0 0; }
.md blockquote { border-left: 3px solid var(--line); padding-left: 10px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.md code {
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}
.md pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  overflow-x: auto;
}
.md pre code { background: none; border: 0; padding: 0; }
.md table { border-collapse: collapse; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.md .align-center { text-align: center; }
.md .align-right { text-align: right; }
.md img { max-width: 100%; border-radius: var(--radius); }

.login { max-width: 340px; margin: 12vh auto; }
.login h1 { font-size: 18px; margin: 0; }

.page-head { margin-bottom: 16px; }
.page-head h1 { font-size: 18px; margin: 0; }
.page-head p { font-size: 13px; margin: 4px 0 0; }

/* Not .card: that is a flex column, which a table cannot be. */
.fleet table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.fleet th, .fleet td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.fleet tbody tr:last-child td { border-bottom: none; }
.fleet th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.fleet td .badge { margin-right: 4px; }
.fleet .box-name { font-weight: 600; margin-right: 8px; }
.fleet .purpose { color: var(--muted); font-size: 13px; margin-top: 2px; max-width: 34ch; }
.fleet .grants .badge.repo { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.fleet .key { text-decoration: none; }

.state {
  font-size: 11px;
  border-radius: 999px;
  padding: 0 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.state-running { color: #17803d; border-color: #17803d; }
.state-stopped { color: #d33; border-color: #d33; }
