:root {
  --paper: #f3f5f4;
  --surface: #ffffff;
  --ink: #1d2a33;
  --muted: #56636c;
  --rule: #d3dadd;
  --done: #2e6b5e;
  --advice: #9a5b00;
  --na: #75818a;
  --focus: #1f5fbf;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151c21;
    --surface: #1d262c;
    --ink: #e6ebee;
    --muted: #a3afb6;
    --rule: #34414a;
    --done: #6fbfa9;
    --advice: #e3a54a;
    --na: #93a0a8;
    --focus: #7fb0ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #151c21; --surface: #1d262c; --ink: #e6ebee; --muted: #a3afb6;
  --rule: #34414a; --done: #6fbfa9; --advice: #e3a54a; --na: #93a0a8; --focus: #7fb0ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.55 var(--font);
}
a { color: inherit; text-underline-offset: 0.2em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem .75rem; z-index: 2; }

.bar {
  display: flex; justify-content: flex-end; gap: 1.25rem;
  padding: .6rem 1.25rem; font-size: .9375rem; color: var(--muted);
  border-bottom: 1px solid var(--rule);
}
.user:empty { display: none; }

.page { max-width: 46rem; margin: 0 auto; padding: 2.5rem 1.25rem 5rem; }

/* Hero: the title and the running tally are the first thing people need */
.hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 .75rem;
  max-width: 18ch;
}
.intro { color: var(--muted); margin: 0 0 1.75rem; max-width: 62ch; }

.progress { margin-bottom: 1rem; }
.progress-bar {
  --pct: 0%;
  height: .5rem; border-radius: 999px; background: var(--rule); overflow: hidden;
}
.progress-bar::after {
  content: ""; display: block; height: 100%; width: var(--pct);
  background: var(--done); transition: width .3s ease;
}
.progress-text { margin: .4rem 0 0; font-weight: 700; }

.tally { display: flex; flex-wrap: wrap; gap: .5rem 1.75rem; margin: 0 0 2rem; }
.tally div { display: flex; align-items: baseline; gap: .4rem; }
.tally dt { color: var(--muted); font-size: .9375rem; }
.tally dd { margin: 0; font-weight: 700; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.tally .t-advice dd { color: var(--advice); }
.tally .t-done dd { color: var(--done); }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem;
  padding: .9rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.filter { display: flex; align-items: center; gap: .5rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; }
.save { flex-basis: 100%; margin: 0; font-size: .875rem; color: var(--muted); }

select, button, .button {
  font: inherit; font-size: .9375rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
  padding: .4rem .8rem; cursor: pointer;
}
button:hover, .button:hover { border-color: var(--ink); }
.button:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); }

.message {
  margin: 1rem 0 0; padding: .6rem .9rem; border-radius: 6px;
  background: var(--surface); border-left: 4px solid var(--done);
}
.message[data-error="true"] { border-left-color: var(--advice); }

/* Groups and items */
.group { margin-top: 2.75rem; }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; }
.group-head h2 { font-size: 1.375rem; margin: 0; }
.group-count { color: var(--muted); font-size: .9375rem; }

.items { list-style: none; margin: 1rem 0 0; padding: 0; }
.item {
  display: grid; grid-template-columns: 3rem 1fr; gap: 1rem;
  padding: 1.25rem 0; border-top: 1px solid var(--rule);
}
.item h3 { font-size: 1.0625rem; margin: .45rem 0 .25rem; line-height: 1.35; }
.detail { margin: 0 0 .75rem; color: var(--muted); max-width: 62ch; }
.detail a { color: var(--ink); white-space: nowrap; margin-left: .25rem; }

/* The ballot square: the one expressive element */
.mark svg { display: block; width: 3rem; height: 3rem; }
.mark .box { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.mark .ink {
  fill: none; stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 60; stroke-dashoffset: 0; animation: draw .35s ease-out;
}
.mark .dot { fill: var(--advice); }
.item[data-status="done"] .ink { stroke: var(--done); }
.item[data-status="advice"] .ink { stroke: var(--advice); }
.item[data-status="na"] .ink { stroke: var(--na); }
.item[data-status="na"] h3 { color: var(--muted); }
@keyframes draw { from { stroke-dashoffset: 60; } }

.status { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: .25rem .7rem; border-radius: 999px;
  border: 1px solid var(--rule); font-size: .875rem; background: var(--surface);
}
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip input:checked + span { color: var(--surface); border-color: transparent; font-weight: 700; }
.chip-todo input:checked + span { background: var(--ink); }
.chip-done input:checked + span { background: var(--done); }
.chip-advice input:checked + span { background: var(--advice); }
.chip-na input:checked + span { background: var(--na); }

.note { margin-top: .6rem; }
.note summary { cursor: pointer; font-size: .9375rem; color: var(--muted); width: max-content; }
.note textarea {
  display: block; width: 100%; margin-top: .4rem; padding: .5rem .6rem;
  font: inherit; font-size: .9375rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; resize: vertical;
}
.stamp { margin: .4rem 0 0; font-size: .8125rem; color: var(--muted); }
.stamp:empty { display: none; }
.empty { margin-top: 2rem; color: var(--muted); }

/* Login page */
.login { max-width: 24rem; margin: 12vh auto; padding: 0 1.25rem; }
.login h1 { font-size: 1.75rem; margin: 0 0 .5rem; }
.login p { color: var(--muted); margin: 0 0 1.5rem; }
.login label { display: block; font-weight: 700; margin: 1rem 0 .3rem; }
.login input {
  width: 100%; font: inherit; padding: .55rem .7rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
}
.login button { margin-top: 1.5rem; width: 100%; padding: .6rem; font-weight: 700; background: var(--ink); color: var(--paper); border-color: var(--ink); }
.login .error { color: var(--advice); font-weight: 700; margin: 0 0 1rem; }

@media (max-width: 34rem) {
  .item { grid-template-columns: 2.25rem 1fr; gap: .75rem; }
  .mark svg { width: 2.25rem; height: 2.25rem; }
  .actions { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mark .ink { animation: none; }
  .progress-bar::after { transition: none; }
}
