:root {
  --bg: #f1f3f5;
  --card: #ffffff;
  --ink: #212529;
  --muted: #868e96;
  --accent: #0b7285;
  --accent-soft: #e3fafc;
  --line: #dee2e6;
  --warn: #e8590c;
  --radius: 14px;
}

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

.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--accent); color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 0;
}
.app-header h1 { margin: 0 0 2px; font-size: 1.25rem; }
.app-sub { margin: 0 0 10px; font-size: .78rem; line-height: 1.3; color: #c5f6fa; }

.tabs { display: flex; gap: 4px; }
.tab {
  flex: 1; border: 0; background: transparent; color: #c5f6fa;
  padding: 10px 4px; font-size: .9rem; cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab[aria-selected="true"] { color: #fff; border-bottom-color: #fff; font-weight: 600; }

main { padding: 16px; max-width: 640px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card h2 { margin: 0 0 12px; font-size: 1rem; }

.muted { color: var(--muted); font-size: .85rem; margin: 4px 0; }
.fineprint { color: var(--muted); font-size: .72rem; font-style: italic; text-align: center; margin: 18px 8px 4px; opacity: .8; }
.warn { color: var(--warn); font-size: .85rem; }

/* date bar */
.date-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.date-bar input { flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 1rem; }
.icon-btn {
  width: 44px; height: 44px; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; font-size: 1.4rem; cursor: pointer;
}

/* habits */
.habit {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.habit:last-child { border-bottom: 0; }
.habit input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.habit small.hint { display: block; color: var(--muted); font-weight: 400; font-size: .78rem; margin-top: 2px; }

/* buttons */
button.primary { -webkit-appearance: none;
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 14px; font-size: 1rem; font-weight: 600; cursor: pointer;
}
#enable-notif { -webkit-appearance: none; width: 100%;
  padding: 13px; border-radius: 10px; border: 1px solid var(--accent);
  background: #fff; color: var(--accent); font-size: 1rem; cursor: pointer;
}

/* calendar */
.month-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.month-bar h2 { flex: 1; text-align: center; margin: 0; font-size: 1.1rem; }
.cal-head, .cal-week { display: grid; grid-template-columns: repeat(7, 1fr) 1.3fr; gap: 4px; }
.cal-head { margin-bottom: 6px; }
.cal-head span { text-align: center; font-size: .72rem; color: var(--muted); }
.cal-head .cal-wk { font-weight: 600; }
.cal-week { margin-bottom: 4px; border-radius: 10px; padding: 2px; }
.cal-day {
  min-height: 46px; border: 1px solid var(--line); border-radius: 8px;
  padding: 3px; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.cal-day .dnum { font-size: .72rem; color: var(--ink); }
.cal-day.other { opacity: .35; }
.cal-day.future .dots i { opacity: .4; }
.cal-day.today { outline: 2px solid var(--accent); }
.dots { display: flex; gap: 2px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.cal-tally {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; font-variant-numeric: tabular-nums; border-radius: 8px;
}
.cal-tally small { font-weight: 400; color: var(--muted); font-size: .7rem; }
.cal-week.gold {
  background: linear-gradient(135deg, #fff3bf, #ffe066);
  box-shadow: 0 0 0 1px #f1c40f, 0 2px 10px rgba(241,196,15,.5);
}
.cal-week.gold .cal-day { background: rgba(255,255,255,.7); border-color: transparent; }
.cal-week.gold .cal-tally { color: #b8860b; }

/* photo backgrounds — Calendar tab (body.cal-bg) and Today tab (body.today-bg) */
body.cal-bg::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(rgba(13, 40, 50, .20), rgba(13, 40, 50, .45)),
    url('../img/calendar-bg.jpg') center / cover no-repeat;
}
body.today-bg::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(rgba(40, 26, 13, .16), rgba(40, 26, 13, .42)),
    url('../img/today-bg.jpg') center / cover no-repeat;
}
body.trees-bg::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(rgba(12, 35, 28, .18), rgba(12, 35, 28, .46)),
    url('../img/trees-bg.jpg') center / cover no-repeat;
}
body.cal-bg .card, body.today-bg .card, body.trees-bg .card {
  background: rgba(255, 255, 255, .70);
  -webkit-backdrop-filter: blur(8px) saturate(1.05);
  backdrop-filter: blur(8px) saturate(1.05);
  border: 1px solid rgba(255, 255, 255, .5);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}
body.cal-bg .icon-btn, body.today-bg .icon-btn { background: rgba(255, 255, 255, .9); border-color: rgba(255, 255, 255, .7); }
body.cal-bg .month-bar h2 { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.85), 0 0 14px rgba(0,0,0,.45); }
body.today-bg .date-bar input {
  background: rgba(255, 255, 255, .70);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-color: rgba(255, 255, 255, .55);
}
body.today-bg #submit-status { color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .75); }
body.trees-bg #trees-status, body.trees-bg .fineprint { color: rgba(255, 255, 255, .92); text-shadow: 0 1px 3px rgba(0, 0, 0, .7); }

/* trees */
.trees-hero { text-align: center; padding: 28px 16px; }
.trees-count span { font-size: 3.4rem; font-weight: 800; color: var(--accent); line-height: 1; }
.trees-label { font-size: 1.1rem; margin-top: 4px; }
.reward-list { list-style: none; margin: 0; padding: 0; }
.reward-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.reward-list li:last-child { border-bottom: 0; }
.reward-actions { display: flex; flex-direction: column; gap: 8px; flex: none; }
.reward-list .primary { padding: 10px 14px; font-size: .9rem; white-space: nowrap; }
.btn-outline {
  -webkit-appearance: none; text-align: center; text-decoration: none;
  padding: 10px 14px; font-size: .9rem; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--accent); border-radius: 10px; color: var(--accent); background: #fff;
}

/* perfect-day celebration */
.celebrate {
  position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.celebrate .pine {
  width: 110px; height: 165px;
  transform: scaleY(0); transform-origin: bottom center;
  transition: transform .9s cubic-bezier(.34, 1.25, .5, 1);
}
.celebrate.show .pine { transform: scaleY(1); }
.celebrate-msg {
  background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 14px;
  max-width: 220px; font-size: .88rem; line-height: 1.35; text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  opacity: 0; transform: translateY(10px); transition: opacity .4s .55s, transform .4s .55s;
}
.celebrate.show .celebrate-msg { opacity: 1; transform: translateY(0); }
.celebrate.hide { opacity: 0; transition: opacity .55s; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #212529; color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: .9rem; z-index: 50;
}
