:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #1a2420;
  --muted: #6b756f;
  --primary: #1f6f4f;
  --primary-dark: #17543c;
  --border: #e1e6e3;
  --danger: #b3392b;
  --overdue: #b3392b;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 72px;
}

#app { max-width: 640px; margin: 0 auto; padding: 16px 16px 24px; }

h1, h2, h3 { margin: 0 0 8px; }

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn:active { background: var(--primary-dark); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 12px; font-size: 0.85rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

input, textarea, select {
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  width: 100%;
  background: #fff;
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.card.clickable { cursor: pointer; }

.progress-bar {
  height: 8px;
  border-radius: 6px;
  background: var(--border);
  overflow: hidden;
  margin: 8px 0;
}
.progress-bar > div {
  height: 100%;
  background: var(--primary);
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.muted { color: var(--muted); font-size: 0.85rem; }

.todo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.todo-row:last-child { border-bottom: none; }
.todo-row .title { flex: 1; }
.todo-row.done .title { text-decoration: line-through; color: var(--muted); }

.checkbox {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: #fff;
  flex-shrink: 0;
}
.checkbox.checked { background: var(--primary); }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--overdue);
  color: #fff;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.topbar .back { background: none; border: none; font-size: 1.4rem; padding: 4px 8px 4px 0; }

nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 10px 0 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.8rem;
}
nav.bottom-nav a.active { color: var(--primary); font-weight: 600; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}
.modal-sheet {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.pairing-screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 20vh;
}
.profile-pick {
  display: flex;
  gap: 10px;
}
.profile-pick button {
  flex: 1;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
}
.profile-pick button.selected { border-color: var(--primary); color: var(--primary); }

.empty-state { color: var(--muted); text-align: center; padding: 24px 0; }
.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 6px; }
