:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a65;
  --border: #e3e1da;
  --accent: #2f6f5e;
  --accent-soft: #e4efe9;
  --warn: #9a5b00;
  --danger: #a33a2c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --surface: #1f1f1d;
    --text: #ecebe6;
    --muted: #a19f97;
    --border: #34332f;
    --accent: #7cc3ab;
    --accent-soft: #23332d;
    --warn: #e0a94e;
    --danger: #f08a7a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .6rem; }
h3 { font-size: .95rem; }
code { font-size: .9em; }
.muted { color: var(--muted); }
.small, small { font-size: .8rem; }
button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: .35rem .75rem;
  cursor: pointer;
}
button:disabled { opacity: .6; cursor: default; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button.danger, .link.danger { color: var(--danger); }
input:not([type=checkbox]) {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .6rem;
  min-width: 0;
}
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.top-right { display: flex; align-items: center; gap: .75rem; }

.notes {
  margin: .75rem 16px 0;
  padding: .6rem .8rem;
  border: 1px solid var(--warn);
  border-radius: 8px;
  color: var(--warn);
}
.notes p { margin: .15rem 0; }

main { padding: 1rem 16px 3rem; max-width: 1200px; margin: 0 auto; }
section { margin-bottom: 1.5rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.stat {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: .6rem .8rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); text-decoration: none;
}
.stat b { font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: .8rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem; }
.tile {
  display: flex; flex-direction: column; gap: .3rem;
  padding: .7rem .8rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.tile h3 a { color: var(--text); }
.tile p { margin: 0; }
.tile .note { font-size: .8rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.counts { display: flex; flex-wrap: wrap; gap: .25rem .7rem; font-size: .85rem; }
.tile-links { display: flex; gap: .8rem; margin-top: auto; padding-top: .3rem; font-size: .85rem; }

.lists { display: grid; gap: 1rem; }
@media (min-width: 900px) {
  .lists { grid-template-columns: 1.3fr 1fr 1fr; align-items: start; }
}
.lists section {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: .8rem;
  margin: 0;
}
.hint { margin: -.3rem 0 .6rem; font-size: .8rem; }

.add-task { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; align-items: center; }
.add-task input[name=title] { flex: 1 1 100%; }
.add-task input[name=group] { flex: 1 1 6rem; }
.later { display: flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); }

.group { margin-bottom: .8rem; }
.group h3 { display: flex; gap: .4rem; align-items: baseline; margin-bottom: .2rem; }
.group ul { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .35rem 0;
  border-top: 1px solid var(--border);
}
.item:first-child { border-top: 0; }
.item input { margin-top: .15rem; flex: none; }
.item .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--muted); margin: .45rem .3rem 0; flex: none; }
.item.priority .dot { background: var(--warn); }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.item-body a { color: var(--text); text-decoration: none; }
.item-body a:hover { text-decoration: underline; }
.item-actions { display: flex; gap: .6rem; font-size: .8rem; flex: none; }
#done-list .item-body span, #done-list .item-body a { color: var(--muted); }

.streaks { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .6rem; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: .1rem .55rem; font-size: .8rem; }
.empty { margin: .2rem 0; font-size: .9rem; }

dialog {
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  width: min(420px, calc(100vw - 32px));
  padding: 1rem;
}
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog form { display: flex; flex-direction: column; gap: .6rem; }
dialog label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); }
dialog label.inline { flex-direction: row; align-items: center; gap: .4rem; }
.dialog-actions { display: flex; gap: .5rem; align-items: center; margin-top: .3rem; }
.spacer { flex: 1; }
.error { color: var(--danger); margin: 0; }
