:root {
  color-scheme: light dark;
  --paper: #f6f4ef;
  --surface: #ffffff;
  --ink: #1f1e1b;
  --ink-2: #5d5a53;
  --ink-3: #9a968c;
  --rule: #e5e1d8;
  --wash: #ece9e2;
  --accent: #2f6b4f;
  --accent-ring: rgba(47, 107, 79, 0.22);
  --accent-muted: #b9d1c3;
  --on-accent: #ffffff;
  --danger: #a4402f;
  --shadow: 0 1px 2px rgba(31, 30, 27, 0.06), 0 4px 16px rgba(31, 30, 27, 0.04);
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141413;
    --surface: #1c1c1a;
    --ink: #edebe6;
    --ink-2: #aaa69d;
    --ink-3: #6f6c65;
    --rule: #2c2b28;
    --wash: #252522;
    --accent: #6fb38f;
    --accent-ring: rgba(111, 179, 143, 0.28);
    --accent-muted: #35503f;
    --on-accent: #10261a;
    --danger: #e08a78;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button, a { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell {
  flex: 1;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: 0 max(1.25rem, env(safe-area-inset-left)) 0 max(1.25rem, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
}

/* Sample-data note */
.sample-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem 0.75rem;
  padding: 0.625rem 1.25rem;
  background: var(--wash);
  color: var(--ink-2);
  font-size: 0.8125rem;
  text-align: center;
}
.sample-note p { margin: 0; }
.sample-note a { color: var(--accent); font-weight: 600; text-underline-offset: 3px; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: max(1rem, env(safe-area-inset-top));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  text-decoration: none;
  min-height: 40px;
}
.brand-mark {
  width: 0.75rem; height: 0.75rem;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: linear-gradient(var(--accent), var(--accent)) center / 0.25rem 0.25rem no-repeat;
}

.tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--wash);
}
.tab {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 0.95rem;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Page head: the date, set like the top of a fresh page */
.page-head { padding: 2.75rem 0 1.5rem; }
.page-head.turn { animation: turn 0.55s cubic-bezier(0.2, 0.7, 0.2, 1); }

.eyebrow {
  margin: 0 0 0.375rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.page-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 2.5rem;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.lede { margin: 0.75rem 0 0; color: var(--ink-2); font-size: 0.9375rem; }

.progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 0;
  color: var(--ink-2);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
.bar {
  width: 5.5rem;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--rule);
}
.bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Add */
.add {
  display: flex;
  gap: 0.5rem;
  padding: 0.375rem 0.375rem 0.375rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.add:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.add input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;
}
.add input::placeholder { color: var(--ink-3); }
.add button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 44px;
  padding: 0 1rem 0 0.8rem;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}
.add button:active { transform: scale(0.97); }
.add button svg, .link-btn svg {
  width: 1rem; height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Tasks */
.tasks { margin: 1rem 0 0; padding: 0; list-style: none; }

.task {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--rule);
}
.task.entering { animation: enter 0.26s cubic-bezier(0.2, 0.7, 0.2, 1); }

.task-check {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 0.95rem 0;
  cursor: pointer;
}
.task-check input {
  position: absolute;
  top: 1rem; left: 0;
  width: 22px; height: 22px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.box {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  margin-top: 1px;
  border: 1.5px solid var(--ink-3);
  border-radius: 50%;
  transition: background-color 0.18s, border-color 0.18s;
}
.box svg {
  width: 13px; height: 13px;
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 16;
  stroke-dashoffset: 16;
  transition: stroke-dashoffset 0.24s ease 0.05s;
}
.task-check:hover .box { border-color: var(--ink-2); }
.task-check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--accent-ring); border-color: var(--accent); }
.task-check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.task-check input:checked + .box svg { stroke-dashoffset: 0; }
.task.popping .box { animation: pop 0.32s cubic-bezier(0.3, 1.6, 0.5, 1); }

.task-text {
  font-size: 1.0625rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-decoration: line-through;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  transition: color 0.2s, text-decoration-color 0.2s;
}
.task.done .task-text { color: var(--ink-3); text-decoration-color: var(--ink-3); }

.task-remove {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  margin: 0.3rem -0.7rem 0 0.25rem;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: opacity 0.15s, color 0.15s, background-color 0.15s;
}
.task-remove svg {
  width: 1rem; height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.task-remove:hover { color: var(--danger); background: var(--wash); }
@media (hover: hover) {
  .task-remove { opacity: 0; }
  .task:hover .task-remove, .task:focus-within .task-remove { opacity: 1; }
}

/* Empty states */
.empty {
  padding: 3.25rem 1rem 1.5rem;
  color: var(--ink-2);
  text-align: center;
}
.empty-mark {
  width: 4.5rem; height: 4.5rem;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.6;
  stroke-linecap: round;
}
.empty h2 {
  margin: 0.875rem 0 0.375rem;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 400;
}
.empty p { max-width: 17rem; margin: 0 auto; font-size: 0.9375rem; }

/* History */
.day { padding: 1.25rem 0 1rem; border-top: 1px solid var(--rule); }
.day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.625rem;
}
.day-title { margin: 0; font-family: var(--serif); font-size: 1.3125rem; font-weight: 400; }
.day-meta { color: var(--ink-3); font-size: 0.8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.h-tasks { margin: 0; padding: 0; list-style: none; }
.h-task {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.3rem 0;
  color: var(--ink);
  font-size: 0.9375rem;
}
.h-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 16px; height: 16px;
  margin-top: 3px;
  border: 1.25px solid var(--ink-3);
  border-radius: 50%;
}
.h-mark svg {
  width: 10px; height: 10px;
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.h-task.done .h-mark { background: var(--accent); border-color: var(--accent); opacity: 0.75; }
.h-task.done .h-text { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.h-text { overflow-wrap: anywhere; }

/* Footer */
.foot {
  margin-top: auto;
  padding: 3.5rem 0 max(1.25rem, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  color: var(--ink-3);
  font-size: 0.8125rem;
}
.saved { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.7; }
.saved.problem .dot { background: var(--danger); }
.foot-actions { display: flex; gap: 0.125rem; margin-left: -0.625rem; }
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 40px;
  padding: 0 0.625rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.8125rem;
  cursor: pointer;
}
.link-btn:hover { background: var(--wash); color: var(--ink); }
.status { flex-basis: 100%; min-height: 1.25rem; margin: 0; color: var(--ink-2); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: calc(100% - 2.5rem);
  padding: 0.375rem 0.375rem 0.375rem 1rem;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 0.75rem);
  transition: opacity 0.2s, transform 0.2s, visibility 0s linear 0.2s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
#toast-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button {
  flex: none;
  min-height: 36px;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent-muted);
  font-weight: 600;
  cursor: pointer;
}
.toast button:hover { background: rgba(255, 255, 255, 0.08); }

/* Confirm dialog */
dialog {
  width: calc(100% - 2.5rem);
  max-width: 23rem;
  padding: 1.5rem;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}
dialog::backdrop { background: rgba(20, 20, 18, 0.38); }
dialog h2 { margin: 0 0 0.5rem; font-family: var(--serif); font-size: 1.375rem; font-weight: 400; }
dialog p { margin: 0 0 0.75rem; color: var(--ink-2); font-size: 0.9375rem; }
.dialog-hint { font-size: 0.8125rem; color: var(--ink-3); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
.dialog-actions button {
  min-height: 42px;
  padding: 0 1.1rem;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-quiet { border: 1px solid var(--rule); background: transparent; color: var(--ink); }
.btn-solid { border: 0; background: var(--ink); color: var(--paper); }

/* Desktop grows from the phone column */
@media (min-width: 48rem) {
  .shell { padding: 0 2rem; }
  .topbar { padding-top: 1.75rem; }
  .page-head { padding: 4.5rem 0 1.75rem; }
  .page-title { font-size: 3.25rem; }
  .tasks { margin-top: 1.25rem; }
  .empty { padding-top: 4rem; }
}

@keyframes turn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes enter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

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