/* Fruitful: warm, calm, tactile. System fonts only, so the app shell works offline. */
:root {
  --bg: #f7f2e8;
  --card: #fffdf8;
  --ink: #2b2a24;
  --muted: #776f5e;
  --line: #e7dfcd;
  --track: #ece4d2;
  --full: #4f7a32;          /* done */
  --full-soft: #e6eed8;
  --min: #c97c12;           /* minimum version */
  --min-soft: #f8e8c8;
  --fruit: #b5452e;         /* brand accent */
  --danger: #a3341f;
  --shadow: 0 1px 2px rgba(60, 50, 20, .06), 0 6px 18px rgba(60, 50, 20, .06);
  --radius: 18px;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17160f; --card: #22211a; --ink: #f1ecdf; --muted: #a59e8a; --line: #34322a; --track: #2f2d25;
    --full: #93bf63; --full-soft: #2a3520; --min: #eaa640; --min-soft: #3b2f18; --fruit: #e2715a; --danger: #ef7d66;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 0 calc(84px + env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: -.01em; }
[hidden] { display: none !important; }
.page { max-width: 560px; margin: 0 auto; padding: 18px 16px 24px; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fruit); }
.muted { color: var(--muted); }

/* ---------- header: day + score ring ---------- */
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 4px 0 16px; }
.day-head h1 { font-size: 34px; line-height: 1.05; }
.day-head .date { margin: 2px 0 0; color: var(--muted); }
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: var(--track); }
.ring .fill { stroke: var(--full); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2, .8, .2, 1); }
.ring .label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring strong { font: 700 24px/1 var(--serif); }
.ring span { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- segmented control ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; margin: 0 0 16px; background: var(--track); border-radius: 999px; }
.seg button { border: 0; background: transparent; padding: 9px 12px; border-radius: 999px; font-weight: 600; color: var(--muted); min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- habit cards ---------- */
.habits { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.habit {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "hit min" "extra extra";
  align-items: center; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: background-color .25s, border-color .25s;
}
.habit[data-status="full"] { background: var(--full-soft); border-color: color-mix(in srgb, var(--full) 45%, transparent); }
.habit[data-status="min"] { background: var(--min-soft); border-color: color-mix(in srgb, var(--min) 55%, transparent); }
.habit-hit { grid-area: hit; display: flex; align-items: center; gap: 14px; text-align: left; border: 0; background: none; padding: 14px 8px 14px 14px; min-height: 64px; border-radius: var(--radius); }
.habit-hit:focus { outline: none; }
.habit-hit:focus-visible { outline: 2px solid var(--full); outline-offset: -3px; }
.habit-body { min-width: 0; display: grid; }
.habit-name { font-weight: 650; font-size: 17px; }
.habit[data-status="full"] .habit-name, .habit[data-status="min"] .habit-name { text-decoration: none; }
.habit-meta { font-size: 13.5px; color: var(--muted); }
.streak.on { color: var(--ink); font-weight: 650; }
.streak.on::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 5px 1px 0; border-radius: 50%; background: var(--fruit); }
.minbtn {
  grid-area: min; margin-right: 12px; border: 1.5px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; min-height: 36px; min-width: 52px;
}
.minbtn[aria-pressed="true"] { background: var(--min); border-color: var(--min); color: #fff; }
.extra { grid-area: extra; display: flex; align-items: center; gap: 10px; padding: 0 14px 14px 60px; font-size: 14px; color: var(--muted); }
.extra input {
  width: 92px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card);
  font-size: 17px; font-variant-numeric: tabular-nums; color: var(--ink);
}
.extra input:focus { outline: 2px solid var(--full); outline-offset: 1px; }
/* counters: tap the card for +1 */
.plus {
  margin-left: auto; flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-weight: 800; font-size: 16px; transition: transform .12s;
}
.habit-hit:active .plus { transform: scale(.9); }
.is-counter .habit-hit { padding-right: 12px; }
.cnt { color: var(--ink); font-variant-numeric: tabular-nums; }
.cnt-n { display: inline-block; font-weight: 800; }
.cnt-n.bump { animation: bump .28s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 0% { transform: scale(1); } 45% { transform: scale(1.35); } 100% { transform: scale(1); } }
.extra.counter { gap: 12px; }
.extra.counter .progress i { background: var(--muted); }
.is-counter[data-status="full"] .progress i { background: var(--full); }
.is-counter[data-status="min"] .progress i { background: var(--min); }
.dec { flex: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; min-height: 36px; font-size: 14px; font-weight: 700; color: var(--muted); }
.dec:disabled { opacity: .4; cursor: default; }
.progress { flex: 1; height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.progress i { display: block; height: 100%; width: var(--pct, 0%); background: var(--fruit); border-radius: inherit; transition: width .5s; }

/* the tick: circle fills, checkmark draws, seeds burst */
.tick { position: relative; width: 34px; height: 34px; flex: none; }
.tick svg { width: 100%; height: 100%; overflow: visible; }
.tick-bg { fill: transparent; stroke: var(--line); stroke-width: 2.5; transition: fill .2s, stroke .2s; }
.tick-mark { fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .25s ease .05s; }
[data-status="full"] .tick-bg { fill: var(--full); stroke: var(--full); }
[data-status="min"] .tick-bg { fill: var(--min); stroke: var(--min); }
[data-status="full"] .tick-mark, [data-status="min"] .tick-mark { stroke-dashoffset: 0; }
.burst { position: absolute; inset: 0; pointer-events: none; }
.burst i { position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px; border-radius: 50%; background: var(--fruit); opacity: 0; }
.pop .tick svg { animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); }
.pop .tick-mark { transition-duration: .35s; }
.pop .burst i { animation: seed .6s ease-out forwards; }
.pop .burst i:nth-child(2n) { background: var(--full); }
.pop[data-status="min"] .burst i:nth-child(2n) { background: var(--min); }
.burst i:nth-child(1) { --dx: 0px; --dy: -26px; }
.burst i:nth-child(2) { --dx: 23px; --dy: -13px; }
.burst i:nth-child(3) { --dx: 23px; --dy: 13px; }
.burst i:nth-child(4) { --dx: 0px; --dy: 26px; }
.burst i:nth-child(5) { --dx: -23px; --dy: 13px; }
.burst i:nth-child(6) { --dx: -23px; --dy: -13px; }
@keyframes pop { 0% { transform: scale(.7); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes seed { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.4); } }
@media (prefers-reduced-motion: reduce) {
  .pop .tick svg, .pop .burst i, .cnt-n.bump { animation: none; }
  .tick-mark, .ring .fill, .progress i { transition: none; }
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 16px 2px 0; font-size: 13.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend .full { background: var(--full); }
.legend .min { background: var(--min); }

/* ---------- week ---------- */
.week-head { margin: 4px 0 16px; }
.week-head h1 { font-size: 30px; }
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 20px; margin-bottom: 12px; }
.area { display: grid; grid-template-columns: 82px minmax(0, 1fr) 46px; align-items: center; gap: 10px; padding: 7px 0; }
.area span { font-weight: 600; }
.area b { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--pct, 0%); background: var(--full); border-radius: inherit; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.days7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 120px; }
.days7 div { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 6px; text-align: center; font-size: 12px; color: var(--muted); }
.days7 .col { align-self: end; height: var(--pct, 0%); min-height: 3px; border-radius: 8px 8px 3px 3px; background: var(--full); }
.days7 .future .col { background: var(--track); }
.days7 .today { color: var(--ink); font-weight: 700; }
.section-title { font-size: 20px; margin: 22px 2px 10px; }
.stepper { grid-area: min; display: flex; align-items: center; gap: 6px; margin-right: 12px; }
.stepper button { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); font-size: 20px; font-weight: 700; line-height: 1; }
.stepper button:disabled { opacity: .35; cursor: default; }
.dots { display: inline-flex; gap: 4px; margin-left: 2px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--track); }
.dots i.on { background: var(--full); }
.signout { display: block; margin: 28px auto 0; border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 10px; }

/* ---------- tabs, banners, toast ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr 1fr;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 16px calc(6px + env(safe-area-inset-bottom));
}
.tabs button { border: 0; background: none; padding: 10px; min-height: 52px; font-weight: 700; color: var(--muted); border-radius: 14px; }
.tabs button[aria-current="page"] { color: var(--ink); background: var(--track); }
.net {
  position: sticky; top: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; font-size: 14.5px; font-weight: 600; background: var(--min-soft); color: var(--ink); border-bottom: 1px solid var(--line);
}
.net.error { background: color-mix(in srgb, var(--danger) 16%, var(--card)); }
.net button { border: 1.5px solid currentColor; background: none; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700; flex: none; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 7;
  max-width: calc(100% - 32px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 15px; box-shadow: var(--shadow);
}
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

/* ---------- login ---------- */
body.no-tabs { padding-bottom: env(safe-area-inset-bottom); }
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: 100%; max-width: 340px; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow); }
.login h1 { font-size: 36px; margin: 16px 0 4px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.login input {
  width: 100%; text-align: center; font-size: 28px; letter-spacing: .4em; padding: 14px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
.login input:focus { outline: 2px solid var(--full); outline-offset: 2px; }
.login button { width: 100%; margin-top: 12px; padding: 14px; border: 0; border-radius: 16px; background: var(--full); color: #fff; font-weight: 700; font-size: 18px; min-height: 52px; }
.login button:disabled { opacity: .6; }
.login .err { color: var(--danger); min-height: 1.4em; margin: 12px 0 0; font-weight: 600; }
