:root {
  --bg: #fbfaf8;
  --fg: #24211d;
  --muted: #8a8378;
  --line: #e5e0d8;
  --accent: #b5651d;
  --card: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --fg: #e8e4dc;
    --muted: #7d776c;
    --line: #2c2a31;
    --accent: #d99a5b;
    --card: #1e1d23;
  }
}

* { box-sizing: border-box; }

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

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

.logout { margin: 0; }
button.link {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; font-size: 14px; padding: 0;
}
button.link:hover { color: var(--accent); }

/* add form */
.add {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
}
.add input[type=text] {
  flex: 1 1 200px; min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--fg); font: inherit;
}
.add input#add-tags { flex: 0 1 160px; }
.add input:focus, .login input:focus, .modal-box textarea:focus, .modal-box input:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}
.add button, .login button, .modal-actions button {
  padding: 10px 16px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: #fff; font: inherit; cursor: pointer;
}
.add button:hover, .login button:hover, .modal-actions button:hover { filter: brightness(1.08); }

/* filters */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); margin-bottom: 16px;
}
.filters label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.tag {
  padding: 2px 8px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); text-decoration: none;
}
.tag:hover { color: var(--accent); border-color: var(--accent); }
.tagsel { color: var(--muted); }
.tagsel b { color: var(--fg); }
.tagsel a { color: var(--accent); }

/* list */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 11px 12px; margin-bottom: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
.item .text { flex: 1; min-width: 0; overflow-wrap: anywhere; cursor: pointer; }
.item .badge { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.item .reps { font-size: 12px; color: var(--muted); }
.item .tags { display: inline-flex; gap: 4px; }
.item .tags i {
  font-style: normal; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px;
}
.item .acts { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.item:hover .acts, .item:focus-within .acts { opacity: 1; }
.item .acts a {
  padding: 2px 5px; color: var(--muted); text-decoration: none; border-radius: 4px;
}
.item .acts a:hover { background: var(--line); color: var(--accent); }

.item.state-COMPLETED .text { text-decoration: line-through; color: var(--muted); }
.item.state-CANCELED .text { text-decoration: line-through; color: var(--muted); font-style: italic; }
.item.state-DELETED { display: none; }
.item.state-REPEATED .text { color: var(--muted); }

.empty { color: var(--muted); padding: 24px 4px; }

/* pager */
.pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 20px; color: var(--muted); font-size: 14px;
}
.pager a { color: var(--accent); text-decoration: none; font-size: 18px; }

/* login */
.login {
  display: flex; flex-direction: column; gap: 10px;
  max-width: 320px; margin-top: 40px;
}
.login label { font-size: 13px; color: var(--muted); }
.login input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--fg); font: inherit;
}

/* modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; width: 100%; max-width: 480px;
}
.modal-box textarea, .modal-box input {
  width: 100%; padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg); font: inherit; resize: vertical;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions button { margin: 0; }
.modal-actions button[data-close] {
  background: none; color: var(--muted); border-color: var(--line);
}
.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
