:root {
  --bg: #f6f4f0;
  --paper: #fffdf9;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #e7e5e4;
  --accent: #1d4e89;
  --accent-hover: #163b68;
  --high: #9a3412;
  --high-bg: #ffedd5;
  --medium: #854d0e;
  --medium-bg: #fef9c3;
  --low: #3f3f46;
  --low-bg: #f4f4f5;
  --radius: 12px;
  --font: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --ui: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.5;
}
.wrap { max-width: 920px; margin: 0 auto; padding: 0 20px 64px; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font-family: var(--font);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.eyebrow {
  margin: 0 0 2px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.top-actions, .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

h1, h2, h3, h4 { font-family: var(--font); font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.8rem; margin: 24px 0 8px; }
h2 { font-size: 1.35rem; margin: 28px 0 8px; }
h3 { font-size: 1.05rem; margin: 20px 0 4px; }
h4 { font-size: 1.05rem; margin: 0; }
.lede, .counts, .sub, .footnote { color: var(--muted); }
.counts { margin-top: 0; font-size: 0.95rem; }
.footnote { margin-top: 40px; font-size: 0.9rem; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
.text-link { font-size: 0.95rem; }

button, .primary, .quiet {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
}
.primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-color: var(--accent);
}
.primary:hover { background: var(--accent-hover); color: #fff; }
.quiet, button.quiet {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.quiet:hover { border-color: var(--muted); color: var(--ink); }

.systems {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px 20px;
  margin: 24px 0;
}
.systems p { color: var(--muted); margin-top: 0; }
.systems ol { margin: 0; padding-left: 22px; }
.systems li { margin: 10px 0; }
.systems li span { display: block; color: var(--muted); font-size: 0.95rem; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  margin: 8px 0 24px;
}
.filters label, .edit-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 140px;
  flex: 1 1 140px;
}
input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
textarea { resize: vertical; }
.check-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  min-width: auto;
  color: var(--ink);
  font-size: 0.95rem;
}
.check-label input { width: auto; }

.group { margin: 8px 0 36px; }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.item {
  display: flex;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.item.is-done { opacity: 0.7; }
.item.is-done h4 { text-decoration: line-through; }
.tick { display: block; padding-top: 3px; }
.tick input { width: 20px; height: 20px; accent-color: var(--accent); }
.item-body { flex: 1; min-width: 0; }
.item-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: space-between;
  align-items: flex-start;
}
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--low-bg);
  color: var(--low);
}
.prio-high { background: var(--high-bg); color: var(--high); }
.prio-medium { background: var(--medium-bg); color: var(--medium); }
.blocks, .fastest, .zero, .link-row, .item-edit, .context, .actions-block { margin: 8px 0 0; font-size: 0.95rem; }
.fastest span, .zero span, .context span, .actions-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.context { white-space: pre-wrap; }
.actions-label { margin: 0 0 6px; }
.action-chips { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.action-form { margin: 0; }
.action-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg);
  cursor: pointer;
}
.action-chip:hover { border-color: var(--accent); }
.action-chip.is-recommended {
  border-color: var(--accent);
  background: #fff;
}
.action-chip .rec {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.action-chip .action-text { white-space: normal; }
.item-edit { margin-top: 10px; }
.empty { color: var(--muted); font-style: italic; }

.edit-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .item { padding: 12px; }
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px 24px;
}
.login-card h1 { margin-top: 0; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.flash {
  background: #fee2e2;
  color: #7f1d1d;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 12px 0 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.note-label, .note-meta {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 6px;
}
.note-form { margin-top: 12px; }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.chip {
  flex: 0 1 auto;
  min-width: 0;
  cursor: pointer;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--bg);
}
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.note-form textarea { margin-bottom: 8px; }
.note-error { color: #7f1d1d; font-size: 0.9rem; margin: 6px 0 0; }
.note-history {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.note-history li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.note-meta { margin: 0 0 4px; }
.note-body { margin: 0; font-size: 0.95rem; }
