/* Tasks — phone-first. One list, three groups, one primary gesture.
   Neutrals biased warm so the surface reads as paper, not chrome. */
:root {
  --bg: #f6f4f0;
  --surface: #fffefc;
  --line: #e4dfd6;
  --line-soft: #efebe3;
  --ink: #22201d;
  --ink-2: #5c564e;
  --ink-3: #8d867c;
  --accent: #9a5b1f;
  --accent-soft: #f6ead9;
  --overdue: #a33a2e;
  --overdue-soft: #f8e6e3;
  --done: #3f7d58;
  --shadow: 0 1px 2px rgba(34,32,29,.05), 0 6px 16px rgba(34,32,29,.04);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131518;
    --surface: #1b1e22;
    --line: #2e333a;
    --line-soft: #23272c;
    --ink: #eceae6;
    --ink-2: #aca69d;
    --ink-3: #7d766d;
    --accent: #dd9448;
    --accent-soft: #33251492;
    --overdue: #e07b6d;
    --overdue-soft: #33201d;
    --done: #6fbf8e;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #131518; --surface: #1b1e22; --line: #2e333a; --line-soft: #23272c;
  --ink: #eceae6; --ink-2: #aca69d; --ink-3: #7d766d; --accent: #dd9448;
  --accent-soft: #33251492; --overdue: #e07b6d; --overdue-soft: #33201d;
  --done: #6fbf8e; --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(2rem + var(--safe-b));
  overscroll-behavior-y: contain;
}

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: max(env(safe-area-inset-top, 0px), .55rem) .8rem .5rem;
  display: flex; flex-direction: column; gap: .55rem;
}
.bar { display: flex; align-items: baseline; gap: .6rem; }
h1 { font-size: 1.15rem; font-weight: 650; letter-spacing: -.01em; }
.digest { font-size: .78rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.signout { margin-left: auto; font-size: .72rem; color: var(--ink-3); text-decoration: none; }
.signout:hover, .signout:focus-visible { color: var(--accent); text-decoration: underline; }
.offline {
  background: var(--overdue-soft); color: var(--overdue); font-size: .78rem;
  font-weight: 600; text-align: center; padding: .35rem; border-radius: 8px;
}
.offline[hidden] { display: none; }

.add { display: flex; gap: .45rem; }
.add input {
  flex: 1; min-width: 0; font: inherit; font-size: 1rem;
  padding: .62rem .75rem; border: 1px solid var(--line);
  border-radius: 11px; background: var(--surface); color: var(--ink);
}
.add input::placeholder { color: var(--ink-3); }
.add input:focus-visible, .add button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.add button {
  flex: 0 0 auto; width: 2.7rem; font-size: 1.35rem; line-height: 1;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); color: var(--accent); cursor: pointer;
}
.add button:active { background: var(--accent-soft); }

.filters { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; font: inherit; font-size: .78rem; font-weight: 600;
  padding: .3rem .68rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- list ---------- */
main { max-width: 46rem; margin: 0 auto; padding: .55rem .8rem 0; }
.group-h {
  font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin: 1rem 0 .35rem .15rem;
}
.group-h:first-child { margin-top: .35rem; }
.group-h.od { color: var(--overdue); }

.task {
  display: flex; align-items: flex-start; gap: .1rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: .4rem; box-shadow: var(--shadow);
  overflow: hidden;
}
.task.is-overdue { border-left: 3px solid var(--overdue); }
.task.is-flagged { border-left: 3px solid var(--accent); }
.task.is-overdue.is-flagged { border-left: 3px solid var(--overdue); }

/* The primary gesture: a big, thumb-sized tick target on the left. */
.tick {
  flex: 0 0 auto; width: 3rem; align-self: stretch; min-height: 3.2rem;
  border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--ink-3);
}
.tick:active { background: var(--accent-soft); }
.tick:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.tick svg { width: 1.15rem; height: 1.15rem; }
.task.done-row .tick { color: var(--done); }

.body {
  flex: 1; min-width: 0; padding: .7rem .8rem .7rem .1rem;
  cursor: pointer; background: transparent; border: 0; text-align: left;
  font: inherit; color: inherit;
}
.body:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.title { display: block; line-height: 1.35; word-wrap: break-word; }
.task.done-row .title { text-decoration: line-through; color: var(--ink-3); }
.meta {
  display: flex; flex-wrap: wrap; gap: .1rem .5rem; margin-top: .18rem;
  font-size: .76rem; color: var(--ink-3);
}
.meta .due-od { color: var(--overdue); font-weight: 600; }
.meta .area { color: var(--ink-2); }
.meta .tg {
  background: var(--accent-soft); color: var(--accent);
  padding: .05rem .38rem; border-radius: 999px; font-size: .72rem; font-weight: 600;
}
.meta .tg.more { background: transparent; color: var(--ink-3); }
.tagrail { padding-top: .1rem; }
.chip.tag { text-transform: lowercase; }
.chip.tag .n {
  margin-left: .3rem; opacity: .55; font-variant-numeric: tabular-nums;
  font-size: .68rem;
}

.empty { color: var(--ink-3); text-align: center; padding: 3rem 1rem; font-size: .92rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(1rem + var(--safe-b)); z-index: 40;
  display: flex; align-items: center; gap: .8rem;
  background: var(--ink); color: var(--bg);
  padding: .6rem .7rem .6rem 1rem; border-radius: 12px;
  font-size: .88rem; box-shadow: 0 8px 28px rgba(0,0,0,.3);
  max-width: calc(100vw - 2rem);
}
.toast[hidden] { display: none; }
.toast button {
  font: inherit; font-weight: 700; color: var(--bg);
  background: transparent; border: 1px solid currentColor;
  border-radius: 8px; padding: .25rem .6rem; cursor: pointer;
}

/* ---------- sheet ---------- */
dialog {
  border: 0; padding: 0; background: transparent; color: var(--ink);
  width: 100%; max-width: 30rem; margin: auto auto 0;
}
dialog::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(2px); }
@media (min-width: 34rem) { dialog { margin: auto; } }
.sheet-inner {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 1rem .9rem calc(1rem + var(--safe-b));
  display: flex; flex-direction: column; gap: .7rem;
}
@media (min-width: 34rem) { .sheet-inner { border-radius: 16px; } }
.sheet-inner h2 { font-size: .95rem; font-weight: 650; }
.sheet-inner label { display: flex; flex-direction: column; gap: .25rem; font-size: .76rem; color: var(--ink-3); }
.sheet-inner input[type=text] {
  font: inherit; font-size: 1rem; color: var(--ink);
  padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 9px; background: var(--bg);
}
.sheet-inner .row { display: flex; gap: .55rem; }
.sheet-inner .row label { flex: 1; min-width: 0; }
.check { flex-direction: row !important; align-items: center; gap: .45rem !important; font-size: .9rem !important; color: var(--ink) !important; }
.notes { border-top: 1px solid var(--line); padding-top: .6rem; }
.notes-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: .3rem; }
.notes-body {
  font-size: .84rem; line-height: 1.55; color: var(--ink-2);
  max-height: 14rem; overflow: auto; word-wrap: break-word;
}
.notes-body h1, .notes-body h2, .notes-body h3 {
  font-size: .88rem; font-weight: 700; color: var(--ink); margin: .5rem 0 .2rem;
}
.notes-body ul { margin: .2rem 0 .4rem 1rem; }
.notes-body li { margin-bottom: .12rem; }
.notes-body code {
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  padding: 0 .25rem; font-size: .8rem;
}
.notes-body pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: .5rem; overflow-x: auto; margin: .3rem 0;
}
.notes-body pre code { border: 0; padding: 0; background: none; }
.notes-body .stamp { color: var(--accent); font-weight: 650; }
.notes-body a { color: var(--accent); }
.sheet-inner textarea {
  font: inherit; font-size: .95rem; color: var(--ink); resize: vertical;
  padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 9px; background: var(--bg);
}
.ctx { font-size: .78rem; color: var(--ink-3); line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; max-height: 8rem; overflow: auto; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .2rem; }
.sheet-actions button {
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
  padding: .5rem .8rem; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
}
.sheet-actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; margin-left: auto; }
.sheet-actions .danger { color: var(--overdue); border-color: color-mix(in srgb, var(--overdue) 40%, transparent); }
.sheet-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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