:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #5f5e5a;
  --accent: #2f6f4f;
  --accent-soft: #dcebe2;
  --accent-strong: #245a3f;
  --warn: #9a4514;
  --warn-soft: #f8e4d6;
  --border: #e3e1db;
  --danger: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --card: #222220;
    --text: #f0efeb;
    --muted: #a3a29d;
    --accent: #6fbf94;
    --accent-soft: #23392d;
    --accent-strong: #8fd3ad;
    --warn: #f0a070;
    --warn-soft: #3e2a1d;
    --border: #34332f;
    --danger: #f2827a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: env(safe-area-inset-top) 0 calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 4px;
}
.top h1 { font-size: 28px; margin: 0; }
.sync { font-size: 12px; color: var(--muted); }

main { padding: 0 16px 96px; max-width: 640px; margin: 0 auto; }
.date { color: var(--muted); margin: 0 0 12px; }
h2 { font-size: 18px; margin: 24px 0 8px; }
.hint, .empty { color: var(--muted); font-size: 14px; }
.empty { text-align: center; margin-top: 48px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px;
}

/* Habits */
.habit { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.habit .name { font-weight: 600; font-size: 17px; }
.habit .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
/* Each day is a 44pt-tall button across the full card width (Apple HIG minimum hit target). */
.week { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, 1fr); margin: 2px -4px -6px; }
.week .day {
  min-height: 44px; min-width: 0; padding: 0; background: none; border-radius: 0;
  display: grid; place-items: center;
}
.week .day span {
  width: 34px; height: 34px; border-radius: 9px; background: var(--border);
  font-size: 13px; font-weight: 500; display: grid; place-items: center; color: var(--muted);
}
.week .day.today span { box-shadow: inset 0 0 0 2px var(--accent); }
.week .day.on span { background: var(--accent); color: #fff; }
.week .day:focus-visible { outline: none; }
.week .day:focus-visible span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check {
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--accent);
  background: transparent; color: var(--accent); font-size: 22px; cursor: pointer;
}
.check.done { background: var(--accent); color: #fff; }
.check { display: grid; place-items: center; }
.check svg { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* Chores */
.chore .head { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.chore .name { font-weight: 600; font-size: 17px; }
.chore .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-weight: 500; }
.badge.overdue { background: var(--warn-soft); color: var(--warn); }
.badge.today { background: var(--accent-soft); color: var(--accent-strong); }
.chore details { margin-top: 8px; }
.chore summary { color: var(--accent); font-size: 14px; cursor: pointer; }
.chore ol { margin: 8px 0 0; padding-left: 20px; }
.chore li { margin: 4px 0; }

/* Controls */
button, .button {
  font: inherit; font-size: 15px; border: 0; border-radius: 10px;
  padding: 10px 14px; background: var(--accent); color: #fff; cursor: pointer;
  display: inline-block;
}
button.secondary, .button.secondary { background: var(--accent-soft); color: var(--accent); }
button.danger { background: transparent; color: var(--danger); }
button.small { padding: 6px 10px; font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.linklike { background: none; color: var(--muted); padding: 0; font-size: 13px; }

.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.form input, .form textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}

dialog {
  border: 0; border-radius: 16px; padding: 20px; width: min(92vw, 480px);
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog h2 { margin-top: 0; }

.fab {
  position: fixed; right: 20px; bottom: calc(80px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; font-size: 30px; line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); padding: 0;
}

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 4px 4px 4px 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); font-size: 15px;
}
.toast[hidden] { display: none; }
.toasting .fab { visibility: hidden; }
.toast button { background: none; color: var(--bg); font-weight: 600; min-height: 44px; text-decoration: underline; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; background: none; color: var(--muted); border-radius: 0; padding: 16px 0;
}
.tabs button.active { color: var(--accent); font-weight: 600; }
