:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #2f6fdf;
  --good: #1f9254;
  --warn-bg: #fff7e6;
  --warn-line: #f5c46b;
  --me: var(--accent);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --card: #181c24;
    --text: #e8eaf0;
    --muted: #98a2b3;
    --line: #2a303c;
    --good: #3fbf7f;
    --warn-bg: #2a2416;
    --warn-line: #7a5d1f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
main { max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 16px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 14px 0 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
p { margin: 8px 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.big { font-size: 1.15rem; font-weight: 600; }
.mono { font-family: ui-monospace, Menlo, monospace; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 8px; }
.center { text-align: center; }

.top { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 12px; }
.captain { margin: 0; color: var(--muted); }
.captain strong { color: var(--text); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
}
.card.attention { background: var(--warn-bg); border-color: var(--warn-line); }

.btn {
  display: inline-block;
  background: var(--me);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
}
.btn.small { padding: 8px 14px; min-height: 40px; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.85rem; text-decoration: underline; padding: 6px; cursor: pointer; }

input, select {
  font: inherit;
  font-size: 16px; /* stops iPhone zooming in on focus */
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row input { flex: 1; min-width: 0; }
.row .btn { flex: none; }
.weekly-fields select { width: auto; flex: none; }
fieldset:has(input[value="daily"]:checked) .weekly-fields,
fieldset:has(input[value="daily"]:checked) .weekly-note { display: none; }
.stack { display: grid; gap: 14px; }
.stack label { display: grid; gap: 6px; font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; }
legend { font-weight: 600; padding: 0 4px; }
label.radio { display: flex !important; gap: 10px; align-items: center; font-weight: 400 !important; padding: 6px 0; }
label.radio input { width: 22px; min-height: 22px; height: 22px; flex: none; }
details summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 6px 0; }
form.inline { display: inline; margin: 0; }

/* Habit tick buttons: the whole row is the tap target */
.day + .day { border-top: 1px dashed var(--line); margin-top: 8px; }
.tick {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin: 0 0 8px;
  font: inherit; color: var(--text); text-align: left;
  cursor: pointer;
  min-height: 56px;
}
.tick .box {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 2px solid var(--muted);
  display: grid; place-items: center;
  font-weight: 700; color: #fff;
}
.tick.done { border-color: var(--me); }
.tick.done .box { background: var(--me); border-color: var(--me); }
.tick.done .label { font-weight: 600; }

.weekly { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0 0 8px; }
.weekly-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar span { display: block; height: 100%; background: var(--me); border-radius: 99px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 0.85rem; }
.chip button { background: none; border: 0; color: var(--muted); font-size: 1.1rem; padding: 2px 8px; cursor: pointer; min-height: 32px; }

/* Route to Augusta */
.route { margin: 6px 0 4px; }
.route-track { position: relative; height: 14px; background: var(--line); border-radius: 99px; margin: 22px 8px 6px; }
.route-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #2f6fdf, #1f9254); border-radius: 99px; }
.walker { position: absolute; top: -24px; transform: translateX(-50%); font-size: 20px; }
.route-ends { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); }
.walk-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.walk-form select, .walk-form .btn { grid-column: span 2; }

.list { list-style: none; padding: 0; margin: 10px 0 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }

/* Group board */
.group { list-style: none; padding: 0; margin: 0; }
.group li { padding: 12px 0 12px 12px; border-left: 4px solid var(--c); margin-bottom: 8px; background: var(--bg); border-radius: 0 10px 10px 0; padding-right: 10px; }
.who { display: flex; align-items: center; gap: 8px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.badge { font-size: 0.75rem; background: var(--c); color: #fff; padding: 2px 8px; border-radius: 99px; }
.habits-today { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.pill { font-size: 0.85rem; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 2px 10px; }
.pill.yes { border-color: var(--good); color: var(--good); font-weight: 600; }

/* Color picker */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch span { display: block; width: 44px; height: 44px; border-radius: 50%; background: var(--c); border: 3px solid transparent; cursor: pointer; }
.swatch input:checked + span { border-color: var(--text); box-shadow: 0 0 0 3px var(--card) inset; }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.install ol { padding-left: 20px; margin: 6px 0; }
.install li { margin: 4px 0; }

/* Bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; max-width: 140px;
  text-align: center;
  padding: 14px 4px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.tabs a.on { color: var(--me); box-shadow: inset 0 3px 0 var(--me); }
