body {
  margin: 0;
  font-family: system-ui, sans-serif;
  color: #222;
  background: #f5f6f8;
}

.nav {
  display: flex;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: #1f2a44;
}

.nav a {
  color: #fff;
  text-decoration: none;
}

.nav-form {
  margin: 0;
}

.error {
  color: #b3261e;
  font-weight: bold;
}

.nav-brand {
  font-weight: bold;
  margin-right: auto;
}

.page {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.card {
  display: block;
  padding: 1.25rem;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #dde0e6;
  color: inherit;
  text-decoration: none;
}

.card:hover {
  border-color: #1f2a44;
}

.task-list {
  padding-left: 1.25rem;
}

.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.add-form input,
.add-form select {
  padding: 0.4rem;
}

.add-title {
  flex: 1 1 100%;
}

.filters a {
  margin-left: 0.5rem;
}

.filters a.active {
  font-weight: bold;
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
}

.edit-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.edit-form input,
.edit-form select {
  padding: 0.4rem;
}

.link-section {
  padding: 0.5rem 1rem;
  border: 2px dashed transparent;
  border-radius: 8px;
}

.link-section.drag-over {
  border-color: #1f2a44;
  background: #eef1f8;
}

dialog {
  max-width: 420px;
  padding: 1.25rem;
  border: 1px solid #dde0e6;
  border-radius: 8px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.task-link {
  color: inherit;
}

.task-done {
  text-decoration: line-through;
  color: #777;
}

.badge {
  margin-left: 0.4rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
  border-radius: 4px;
  background: #e8eaee;
  white-space: nowrap; /* keep "overdue: 2026-10-01" on one line */
}

/* ...except the note's task badge, which holds a whole task title */
.badge-task {
  white-space: normal;
}

.priority-high .badge-priority {
  background: #f6d5d2;
}

.priority-low .badge-priority {
  background: #dcebdd;
}

.badge.overdue {
  background: #b3261e;
  color: #fff;
}

.inline-form {
  display: inline;
  margin-left: 0.5rem;
}

.note-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.note-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem;
  font-family: inherit;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.note-list {
  list-style: none;
  padding: 0;
}

.note-list li {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid #dde0e6;
  border-radius: 8px;
}

/* Keep the line breaks the user typed */
.note-text {
  margin: 0 0 0.25rem;
  white-space: pre-wrap;
}

.muted {
  color: #777;
}

/* Long web addresses and words shouldn't push the page wider than the screen */
.muted,
.note-text {
  overflow-wrap: anywhere;
}

select {
  max-width: 100%;
}

.nav-brand {
  white-space: nowrap;
}

.nav-form button {
  color: #fff;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  cursor: pointer;
}

/* Phones and other narrow screens */
@media (max-width: 600px) {
  .nav {
    flex-wrap: wrap;
    align-items: center;
    gap: 0 1rem;
    padding: 0.25rem 1rem;
  }

  .nav a,
  .nav-form button {
    padding: 0.6rem 0;
  }

  .nav-form button {
    padding: 0.4rem 0.8rem;
  }

  .page {
    margin: 1rem auto;
  }

  h1 {
    font-size: 1.6rem;
  }

  /* Big enough to tap, and 16px text so iPhones don't zoom in when you tap a field */
  button,
  input,
  select,
  textarea {
    font-size: 1rem;
  }

  button,
  select,
  input:not([type="checkbox"]) {
    min-height: 2.75rem;
  }

  button {
    padding: 0 0.9rem;
  }

  input[type="checkbox"] {
    width: 1.4rem;
    height: 1.4rem;
  }

  a.inline-form {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 0.5rem;
  }

  .filters a {
    display: inline-block;
    padding: 0.5rem;
  }

  /* Forms: one field per row, full width */
  .add-form input,
  .add-form select,
  .add-form button {
    flex: 1 1 100%;
  }

  .edit-form {
    max-width: none;
  }

  .note-form {
    align-items: stretch;
  }

  .note-actions > * {
    flex: 1 1 100%;
  }

  /* Lists: no bullets; each item is a row whose title takes the full width */
  .task-list,
  .note-list {
    list-style: none;
    padding: 0;
  }

  .task-list li,
  .note-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
  }

  .task-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #e3e6ec;
  }

  .task-list li > a:first-child,
  .note-text {
    flex: 1 1 100%;
  }

  .badge,
  .inline-form {
    margin-left: 0;
  }

  /* Done and Delete sit together on their own row under the task */
  .actions {
    display: flex;
    flex: 1 1 100%;
    gap: 0.5rem;
  }

  /* The "Add to task" dropdown and its button share one full-width row */
  .attach-form {
    display: flex;
    flex: 1 1 100%;
    gap: 0.5rem;
    min-width: 0; /* without this a long option stops the row shrinking to fit the screen */
  }

  .attach-form select {
    flex: 1;
    min-width: 0;
  }

  .link-section {
    padding: 0.5rem 0;
  }

  dialog {
    width: calc(100% - 2rem);
    box-sizing: border-box;
  }
}
