@font-face {
  font-family: "Anybody";
  src: url("fonts/anybody.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #F5F7F2;
  --ink: #133D2C;
  --faded: #557063;
  --green: #009A55;
  --pink: #FF48B0;
  --tint: #DCEFE2;
  --pink-hl: #FAA8D4;
  --dots: #87CDAB;
  --dock-h: 128px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.4 "Atkinson Hyperlegible Next", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.display {
  font-family: "Anybody", system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.faded { color: var(--faded); font-size: 15px; }

main {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(var(--dock-h) + env(safe-area-inset-bottom) + 24px);
}

/* Date heading, printed twice: pink slightly off-register under forest ink */
.mis {
  position: relative;
  font-size: min(39px, calc(10vw - 4.5px)); /* "30 September" must fit on one line */
  line-height: 0.98;
  margin: 0;
  white-space: pre-line;
  isolation: isolate;
}
.mis-pink {
  position: absolute;
  left: 3px;
  top: 2px;
  color: var(--pink);
}
.mis-ink {
  position: relative;
  mix-blend-mode: multiply;
}
.summary { margin: 12px 0 12px; }

.empty {
  color: var(--faded);
  margin: 32px 0;
}

/* Bottom dock: the one text field plus the two tabs */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 440px;
  margin: 0 auto;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 6px);
  background: var(--paper);
}
.field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  border-radius: 12px;
  background: var(--tint);
  padding: 0 7px 0 16px;
  color: var(--faded);
}
.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 17px;
  outline: none;
}
.field input::placeholder { color: var(--faded); }
.field:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.add-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--pink);
  color: var(--ink);
  display: grid;
  place-items: center;
  flex: none;
}
.tabs {
  display: flex;
  justify-content: space-around;
}
.tabs button {
  min-width: 88px;
  min-height: 44px;
  font-size: 15px;
  color: var(--faded);
}
.tabs button[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline 4px var(--green);
  text-underline-offset: 6px;
}

.icon-btn {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--faded);
}

/* Task rows sit straight on the paper, divided by a row of printed dots */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.task {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  background: radial-gradient(circle, var(--dots) 1.5px, transparent 1.8px) 0 100% / 8px 4px repeat-x;
  overflow: hidden;
}
.task.folding {
  height: 0 !important;
  min-height: 0;
  opacity: 0;
  transition: height 0.2s ease, min-height 0.2s ease, opacity 0.2s ease;
}
.check {
  position: relative;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--ink);
}
.check::before { /* bigger tap target */
  content: "";
  position: absolute;
  inset: -9px;
}
.check .ink {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--green);
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.check .ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 3px solid var(--pink);
  mix-blend-mode: multiply;
  transform: translate(3px, -2px);
  opacity: 0;
  transition: opacity 0.12s;
}
.task-main {
  flex: 1;
  min-width: 0;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  color: var(--ink);
}
.task-main svg { color: var(--faded); flex: none; }
.title {
  position: relative;
  min-width: 0;
  overflow-wrap: anywhere;
}
.title .strike {
  position: absolute;
  left: -3px;
  top: 45%;
  height: 10px;
  width: 0;
  background: var(--green);
  mix-blend-mode: multiply;
  opacity: 0.6;
  transition: width 0.26s ease-out 0.12s;
}
.due {
  margin-left: auto;
  flex: none;
  color: var(--faded);
  font-size: 15px;
}
.overdue, .highlight {
  background: var(--pink-hl);
  color: var(--ink);
  padding: 1px 6px;
  border-radius: 3px;
}
.task.done .ink { transform: scale(1); }
.task.done .ring { opacity: 1; }
.task.done .strike { width: calc(100% + 6px); }

/* Toast: a printed ticket in forest ink, with a pink countdown bar.
   It is a popover so it can sit above an open sheet. */
.toast {
  position: fixed;
  inset: auto 20px calc(var(--dock-h) + env(safe-area-inset-bottom) + 12px);
  width: auto;
  max-width: 400px;
  margin: 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
}
.toast:popover-open {
  display: flex;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
}
#toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#toast-undo {
  font-weight: 600;
  text-decoration: underline;
  min-height: 32px;
}
.toast-life {
  flex-basis: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--pink);
  transform-origin: left;
}
.toast-life.running {
  transform: scaleX(0);
  transition: transform 5s linear;
}

/* Bottom sheets */
.sheet {
  width: 100%;
  max-width: 440px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--tint);
  color: var(--ink);
}
.sheet[open] { animation: sheet-up 0.28s ease-out; }
.sheet::backdrop { background: rgba(19, 61, 44, 0.38); }
@keyframes sheet-up {
  from { transform: translateY(100%); }
}
.sheet-body {
  display: flex;
  flex-direction: column;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 24px);
}
.sheet-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
}
.sheet-bar button { min-height: 44px; font-size: 17px; }
.pill {
  background: var(--pink);
  font-weight: 600;
  padding: 0 18px;
  border-radius: 999px;
}
.sheet h2 { font-size: 26px; margin: 8px 0 4px; }
.title-input {
  font-size: 30px;
  border: 0;
  background: none;
  padding: 8px 0 16px;
  outline: none;
  border-bottom: 3px dotted var(--dots);
}
.sheet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  border-bottom: 3px dotted var(--dots);
}
.sheet-row label { flex: 1; }
.sheet-row input {
  border: 0;
  background: none;
  font-size: 17px;
  min-height: 44px;
}
.notes-label { margin: 16px 0 6px; }
.sheet textarea {
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  padding: 10px 12px;
  resize: vertical;
}
#task-delete {
  align-self: flex-start;
  margin-top: 28px;
  min-height: 36px;
  padding: 2px 10px;
}

/* Year view: weeks as rows, newest on top, a tally per day */
.year-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.year-head > div { flex: 1; }
.streak {
  font-size: 27px;
  line-height: 1.08;
  margin: 0;
}
#best { margin: 8px 0 0; }
.week-head, .year-grid {
  display: grid;
  grid-template-columns: 40px repeat(7, minmax(0, 1fr));
  gap: 3px;
}
.week-head {
  text-align: center;
  margin: 18px 0 6px;
}
.month {
  align-self: start;
  padding-top: 4px;
  font-size: 14px;
  line-height: 1.2;
  color: var(--faded);
  white-space: pre-line;
}
.day {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
}
.day svg { display: block; }
.day.today::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  border: 3px solid var(--pink);
  mix-blend-mode: multiply;
  transform: translate(2px, -2px);
}
.day.fresh svg { animation: print-in 0.45s ease-out 0.15s backwards; }
@keyframes print-in {
  from { opacity: 0; transform: scale(1.3); }
}
.tally {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.6;
  stroke-linecap: round;
}
.empty-dot { fill: var(--green); opacity: 0.35; }

/* Search results replace the grid while typing */
.results {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.result {
  display: flex;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 12px 0;
  text-align: left;
  border-bottom: 3px dotted var(--dots);
}
.result .when { flex: none; width: 100px; padding-top: 1px; }

/* Day panel */
.done-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.done-row {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 3px dotted var(--dots);
}
.done-row .time { flex: none; width: 72px; padding-top: 1px; white-space: nowrap; }
.done-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.done-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  font-size: 15px;
}
.btn.highlight { border-color: var(--pink-hl); }
#backup-sheet .btn {
  margin-top: 12px;
  min-height: 52px;
  font-size: 17px;
}

.haptic {
  position: fixed;
  left: -100px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
