:root {
  --bg: #faf9f7;
  --card: #ffffff;
  --fg: #1c1c1a;
  --muted: #6f6e68;
  --line: #e6e4de;
  --accent: #3a7d5c;
  --accent-soft: #e4efe8;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141513;
    --card: #1d1f1c;
    --fg: #e9e7e1;
    --muted: #93928b;
    --line: #2b2d29;
    --accent: #64ac85;
    --accent-soft: #23342b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#view {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.35rem; margin: 8px 0 2px; font-weight: 650; }
h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 26px 0 8px; font-weight: 600; }
.sub { color: var(--muted); font-size: 0.92rem; margin: 0 0 4px; }

/* Bottom nav */
#nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 10px 4px calc(10px + env(safe-area-inset-bottom));
}
#nav a {
  color: var(--muted); text-decoration: none; font-size: 0.82rem; font-weight: 600;
  padding: 6px 10px; border-radius: 999px;
}
#nav a.active { color: var(--accent); background: var(--accent-soft); }

/* Cards + rows */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 10px 0;
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 8px 0;
  min-height: 60px;
}
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .meta { color: var(--muted); font-size: 0.82rem; }

/* One-tap done toggle */
.check {
  width: 46px; height: 46px; flex: none;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: transparent;
  color: transparent;
  font-size: 1.2rem;
  cursor: pointer;
}
.check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.done-label { text-decoration: line-through; color: var(--muted); }
.skipped .title { color: var(--muted); }

button, .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.small { padding: 5px 12px; font-size: 0.82rem; }
button.ghost { border: none; background: none; color: var(--muted); }
.linkish { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 4px; }

/* Skip reason chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { padding: 6px 12px; font-size: 0.82rem; }

/* Quiet status line */
.statusline { color: var(--muted); font-size: 0.9rem; text-align: center; margin: 18px 0; }
.statusline strong { color: var(--fg); }

/* Nudge — calm, not alarming */
.nudge { border-color: var(--accent); background: var(--accent-soft); }
.nudge p { margin: 0 0 10px; }

.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: 2px;
}
.tag.accent { color: var(--accent); border-color: var(--accent); }
.tag.proposed { color: var(--accent); border-style: dashed; border-color: var(--accent); }

/* Week */
.weeknav { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }
.dayblock { margin: 14px 0; }
.dayblock.today-day h3 { color: var(--accent); }
.dayblock h3 { font-size: 0.92rem; margin: 0 0 4px; }
.dayblock h3 .date { color: var(--muted); font-weight: 400; }

/* Calendar */
.tabs { display: flex; gap: 6px; margin: 12px 0; }
.tabs button { flex: 1; }
.tabs button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dowh { text-align: center; color: var(--muted); font-size: 0.72rem; padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.85rem; cursor: pointer; background: none; color: var(--fg); padding: 0;
}
.cal-cell:hover { border-color: var(--line); }
.cal-cell.other { color: var(--line); }
.cal-cell.today { border-color: var(--accent); font-weight: 700; }
.cal-cell.selected { background: var(--accent-soft); }
.dots { display: flex; gap: 2px; height: 6px; margin-top: 2px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.dot.event { background: var(--accent); }
.mini-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-month { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer; text-align: center; }
.mini-month h4 { margin: 0 0 6px; font-size: 0.8rem; }
.mini-month .mgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-month .md { width: 100%; aspect-ratio: 1; border-radius: 50%; font-size: 0; }
.mini-month .md.has-event { background: var(--accent); }
.mini-month .md.has-session { background: var(--line); }

/* History charts */
.chart { width: 100%; height: auto; }
.bar-track { background: var(--line); border-radius: 999px; height: 8px; flex: 1; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 999px; }

/* Forms / sheet */
dialog#sheet {
  border: none; border-radius: var(--radius) var(--radius) 0 0;
  background: var(--card); color: var(--fg);
  width: 100%; max-width: 640px;
  margin: auto auto 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
dialog#sheet::backdrop { background: rgba(0,0,0,0.4); }
dialog#sheet h3 { margin-top: 0; }
dialog#sheet form { display: flex; flex-direction: column; gap: 10px; }
input, select, textarea {
  font: inherit; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; width: 100%;
}
.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* PIN screen */
#pin-screen {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
#pin-screen[hidden] { display: none; }
#pin-form { width: min(320px, 86vw); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.error { color: #b3593a; min-height: 1.2em; margin: 0; }

/* Toast */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  background: var(--fg); color: var(--bg);
  padding: 9px 16px; border-radius: 999px; font-size: 0.88rem;
  z-index: 60; max-width: 88vw;
}

.suggestions .card { border-color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
