:root {
  color-scheme: light dark;
  --paper: #f8f7f3;
  --surface: #fffefa;
  --ink: #26362d;
  --muted: #657369;
  --line: #d9ded5;
  --accent: #2b6547;
  --error: #9e3229;
  font: 16px/1.5 system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

main {
  max-width: 640px;
  margin: auto;
  padding: 44px 20px calc(120px + env(safe-area-inset-bottom));
}

.brand {
  color: var(--accent);
  letter-spacing: .2em;
  font-size: .7rem;
  font-weight: 700;
  margin: 0;
}

h1 {
  font-size: 3.5rem;
  line-height: 1.15;
  letter-spacing: -.06em;
  margin: 10px 0 24px;
  font-weight: 600;
}

h1 span {
  color: var(--accent);
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  gap: 12px;
}

#count, #status {
  color: var(--muted);
  font-size: .875rem;
  margin: 0;
}

#status {
  margin: 12px 0 24px;
}

#error {
  color: var(--error);
}

#empty {
  color: var(--muted);
  padding: 48px 0;
}

#list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.task {
  display: grid;
  grid-template-columns: 48px minmax(0,1fr) 48px;
  align-items: center;
  border-top: 1px solid var(--line);
  gap: 4px;
  padding: 6px 0;
}

button, input {
  font: inherit;
}

button {
  min-height: 48px;
  min-width: 48px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  background: transparent;
  color: var(--accent);
}

button:hover {
  background: var(--line);
}

button:disabled, input:disabled {
  opacity: .55;
  cursor: default;
}

input {
  min-width: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
}

.check {
  display: grid;
  place-items: center;
  min-height: 48px;
}

.check input {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
  cursor: pointer;
}

.edit {
  width: 100%;
  min-height: 48px;
  padding: 8px;
  border-radius: 8px;
}

.done .edit:not(:focus) {
  text-decoration: line-through;
  color: var(--muted);
}

.edit:focus {
  background: var(--surface);
}

.delete {
  font-size: 1.5rem;
  color: var(--muted);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#add {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%,640px);
  display: flex;
  gap: 8px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
}

#text {
  flex: 1;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

#add button {
  background: var(--accent);
  color: var(--surface);
  padding: 0 20px;
  font-weight: 600;
}

.visually_hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

@media (min-width: 640px) {
  main {
    padding-top: 80px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #18221d;
    --surface: #223027;
    --ink: #e4ebe2;
    --muted: #a3b2a4;
    --line: #36473b;
    --accent: #a2d1a7;
    --error: #ffaca1;
  }
}
