:root {
  --paper: #fbf9f4;
  --panel: #f4f1e9;
  --ink: #1f1d1a;
  --muted: #8a857c;
  --rule: #ebe6db;
  --accent: #2f7a52;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe6;
  --done: #aaa49a;
  --warn: #a4471f;
  --now: #d2453b;
  --now-soft: #f8e1dc;
  --gutter: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #181715;
    --panel: #1f1e1b;
    --ink: #ece8e1;
    --muted: #8d887f;
    --rule: #2b2926;
    --accent: #5fb487;
    --accent-ink: #0f1a14;
    --accent-soft: #22342a;
    --done: #6b665e;
    --warn: #e58a62;
    --now: #ef6b5b;
    --now-soft: #3a2320;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font: 400 20px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  cursor: text;
}

/* Checklist on the left, the day's calendar in a column on the right. */
.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: 100dvh;
}

.pad {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) 24px 40vh;
}

/* Next task: {name} in {time left} */
.next {
  display: inline-block;
  max-width: 100%;
  margin: 0 0 22px;
  padding: 8px 16px 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 15px;
  line-height: 1.35;
  cursor: default;
}

.next::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}

.next strong { font-weight: 650; }
#next-when { font-variant-numeric: tabular-nums; }

.next.due { background: var(--now-soft); }
.next.due::before { background: var(--now); animation: pulse 1.2s ease-in-out infinite; }

.next.empty {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--rule);
  color: var(--muted);
}

.next.empty::before { background: var(--rule); }

@keyframes pulse { 50% { opacity: .25; } }

@media (prefers-reduced-motion: reduce) {
  .next.due::before { animation: none; }
}

.head { margin-bottom: 16px; cursor: default; }

h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.dot { margin: 0 4px; }

.warn { margin: 8px 0 0; color: var(--warn); font-size: 15px; }

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

.item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
}

.item.draft { border-bottom: 0; }

/* Round checkbox, vertically centred on the first line of text (30px). */
.box {
  appearance: none;
  flex: none;
  display: grid;
  place-content: center;
  width: 24px;
  height: 24px;
  margin: 3px 0 0;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}

.box::after {
  content: "";
  width: 11px;
  height: 6px;
  border-left: 2.5px solid var(--accent-ink);
  border-bottom: 2.5px solid var(--accent-ink);
  transform: translate(0, -1px) rotate(-45deg) scale(0);
  transition: transform .15s;
}

.box:checked { background: var(--accent); border-color: var(--accent); }
.box:checked::after { transform: translate(0, -1px) rotate(-45deg) scale(1); }
.box:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.ghost {
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 3px;
  border: 2px dashed var(--rule);
  border-radius: 50%;
}

.text {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.5;
}

.text::placeholder { color: var(--muted); }

.done .text {
  color: var(--done);
  text-decoration: line-through;
  text-decoration-color: var(--done);
}

/* The time read from the item's text. */
.when {
  flex: none;
  margin-top: 4px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  line-height: 22px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: default;
}

.done .when { background: transparent; color: var(--done); }

.del {
  flex: none;
  width: 32px;
  height: 32px;
  margin-top: -1px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}

.item:hover .del,
.item:focus-within .del,
.del:focus-visible { opacity: 1; }

.del:hover { background: var(--rule); color: var(--ink); }
.del:focus-visible { outline: 2px solid var(--accent); }

@media (hover: none) {
  .del { opacity: .45; }
}

/* "Suggest items": a small link-style button fixed to the bottom of the list
   column, lined up with the item text. Content scrolling under it fades out. */
.dock {
  position: fixed;
  left: 0;
  right: 340px; /* The calendar column. */
  bottom: 0;
  z-index: 5;
  padding-top: 24px;
  background: linear-gradient(to top, var(--paper) 55%, transparent);
  pointer-events: none;
}

.dock-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px max(12px, env(safe-area-inset-bottom));
}

@media (max-width: 900px) {
  .dock { right: 0; }
  .cal { padding-bottom: 56px; } /* Room for the dock over the calendar's last hour. */
}

@media (max-width: 520px) {
  .dock-inner { padding-left: 18px; padding-right: 12px; }
}

.suggest {
  margin: 0 0 0 38px;
  padding: 2px 0;
  pointer-events: auto;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: text-decoration-color .15s;
}

.suggest:hover { text-decoration-color: currentColor; }
.suggest:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Suggested rows flash in so it's clear what arrived. */
.item.fresh { animation: fresh 1.8s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } }

@media (prefers-reduced-motion: reduce) {
  .item.fresh { animation: none; }
}

/* Calendar column */
.cal {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--rule);
  cursor: default;
}

.cal-head {
  position: sticky;
  top: 0;
  z-index: 3;
  margin: 0;
  padding: max(40px, env(safe-area-inset-top)) 20px 14px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.cal-grid { position: relative; margin: 12px 16px 32px 0; }

.hour {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hour span { width: calc(var(--gutter) - 8px); text-align: right; }
.hour::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }

.ev {
  position: absolute;
  z-index: 1;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.ev time { flex: none; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.ev span { overflow: hidden; text-overflow: ellipsis; }
.ev.past { opacity: .6; }
.ev.done { opacity: .45; }
.ev.done span { text-decoration: line-through; }
.ev:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.now {
  position: absolute;
  z-index: 2;
  left: calc(var(--gutter) - 4px);
  right: 0;
  height: 0;
  border-top: 2px solid var(--now);
  pointer-events: none;
}

.now::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--now);
}

/* Narrow screens: the calendar drops below the list. */
@media (max-width: 900px) {
  .page { grid-template-columns: minmax(0, 1fr); } /* A plain 1fr won't shrink below the rows' content. */
  .pad { padding-bottom: 32px; }
  .cal {
    position: static;
    height: auto;
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
  .cal-head { position: static; padding-top: 24px; }
}

@media (max-width: 520px) {
  body { font-size: 18px; }
  h1 { font-size: 34px; }
  .pad { padding-left: 18px; padding-right: 12px; }
  .box, .ghost { margin-top: 1.5px; }
  .when { margin-top: 2px; }
}
