:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #15171c;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2f6fed;
  --accent-soft: #e8efff;
  --good: #14a46b;
  --good-soft: #e3f6ee;
  --warn: #d9822b;
  --warn-soft: #fdf0e1;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #191c22;
    --text: #eef0f4;
    --muted: #9aa1ad;
    --line: #2a2e37;
    --accent: #6e9bff;
    --accent-soft: #1f2a44;
    --good: #3fcf8e;
    --good-soft: #17322a;
    --warn: #f0a457;
    --warn-soft: #3a2a18;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Heebo", "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom));
}
main { max-width: 640px; margin: 0 auto; padding: 16px; }

h1 { font-size: 26px; margin: 8px 0 2px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

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

/* motivation */
.motivation {
  background: linear-gradient(135deg, var(--accent-soft), var(--card));
  border-color: transparent;
}
.motivation .quote { font-size: 19px; font-weight: 600; line-height: 1.45; margin: 0 0 8px; }
.motivation .note { color: var(--muted); font-size: 14px; margin: 0 0 10px; }

/* progress ring */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ring { --p: 0; width: 56px; height: 56px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--good) calc(var(--p) * 1%), var(--line) 0);
  display: grid; place-items: center; }
.ring::after { content: attr(data-label); width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); display: grid; place-items: center; font-size: 13px; font-weight: 700; }

/* lists */
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item .icon { font-size: 22px; width: 28px; text-align: center; }
.item .grow { flex: 1; min-width: 0; }
.item .meta { color: var(--muted); font-size: 13px; }
.item.done .title { color: var(--muted); text-decoration: line-through; }

.check {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); background: transparent; color: #fff;
  font-size: 18px; cursor: pointer; display: grid; place-items: center;
  transition: transform .12s, background .15s, border-color .15s;
}
.check:active { transform: scale(.9); }
.check.on { background: var(--good); border-color: var(--good); }

.meal.late { background: var(--warn-soft); border-radius: 12px; padding-inline: 10px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* buttons + forms */
button.btn, .btn {
  border: 0; border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent); padding: 6px 10px; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.danger { background: transparent; color: #e5484d; padding: 6px 10px; }

label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 70px; resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .none { flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; font-size: 16px; padding: 0; margin-bottom: 4px; }

/* habit heatmap */
.heat { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; margin-top: 8px; direction: ltr; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--line); }
.heat i.on { background: var(--good); }
.heat i.today { outline: 2px solid var(--accent); outline-offset: 1px; }

/* integrations */
.integ { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.integ:last-child { border-bottom: 0; }

/* tab bar */
.tabbar {
  position: fixed; inset: auto 0 0 0; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabbar button {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 14px; cursor: pointer;
}
.tabbar button span { font-size: 22px; filter: grayscale(1); opacity: .7; }
.tabbar button.active { color: var(--accent); font-weight: 600; }
.tabbar button.active span { filter: none; opacity: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { color: var(--muted); text-align: center; padding: 12px; }

/* ---- v0.2 additions (functional; design pass later) ---- */
.meta { color: var(--muted); font-size: 13px; }
.meta a { color: var(--accent); }
.item.late { background: var(--warn-soft); border-radius: 12px; padding-inline: 10px; }
.quick { display: flex; gap: 8px; margin-bottom: 14px; }
.quick input { flex: 1; font-size: 16px; padding: 12px 14px; border-radius: 14px; background: var(--card); }
.quick .btn { font-size: 20px; padding: 0 18px; }
.insight { border-inline-start: 4px solid var(--accent); background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.insight.good { border-color: var(--good); }
.insight.warn { border-color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; text-align: center; }
.stats div { background: var(--bg); border-radius: 12px; padding: 10px 4px; }
.stats b { display: block; font-size: 20px; }
.stats span { font-size: 12px; color: var(--muted); }
.pos { color: var(--good); } .neg { color: #e5484d; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; }
th { color: var(--muted); font-weight: 600; }
.bars > div, .catbar { margin: 8px 0; position: relative; }
.bars i, .catbar i { display: block; height: 8px; border-radius: 99px; background: var(--line); position: relative; overflow: hidden; margin-top: 4px; }
.bars i::after, .catbar i::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--good); border-radius: 99px; }
[dir=rtl] .bars i::after, [dir=rtl] .catbar i::after { inset: 0 0 0 auto; }
.catbar.over i::after { background: #e5484d; }
.catbar .row { font-size: 14px; }
.catbar u { position: absolute; bottom: 0; right: var(--x); width: 2px; height: 12px; background: var(--text); }
.lesson p { margin: 6px 0 0; font-size: 15px; }
.navcard { display: flex; gap: 14px; align-items: center; width: 100%; text-align: start; font: inherit; color: inherit; cursor: pointer; }
.navcard > span { font-size: 26px; }
.steps { padding-inline-start: 20px; font-size: 14px; line-height: 1.8; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 12px; direction: ltr; unicode-bidi: embed; word-break: break-all; }
code.copy { cursor: copy; }
pre.plan { white-space: pre-wrap; font: inherit; font-size: 14px; color: var(--muted); margin: 6px 0; }
details summary { cursor: pointer; padding: 6px 0; color: var(--accent); }
.planDay { border-top: 1px solid var(--line); padding: 8px 0; }
.catsel { width: auto; font-size: 12px; padding: 4px 6px; max-width: 110px; }
.tx b { min-width: 70px; text-align: left; }
button[disabled] { opacity: .5; }
.tabbar button { padding: 4px 8px; }

/* connections page */
.conn summary { display: flex; align-items: center; gap: 12px; list-style: none; cursor: pointer; color: inherit; padding: 0; }
.conn summary::-webkit-details-marker { display: none; }
.conn summary .grow { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.conn-icon { font-size: 28px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; }
.pill.on { background: var(--good-soft); color: var(--good); font-weight: 600; }
.conn[open] summary { padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.conn-status { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.conn-body p { margin: 0 0 10px; font-size: 15px; }
.steps.big { font-size: 15px; line-height: 1.7; padding-inline-start: 22px; }
.steps.big li { margin-bottom: 8px; }
.errbox { background: #e5484d22; border: 1px solid #e5484d66; border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.okbox { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.explain p { font-size: 14px; color: var(--muted); margin: 6px 0 12px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.progress i { display: block; height: 100%; width: var(--w); background: var(--good); margin-inline-start: 0; }
a.btn { text-decoration: none; display: inline-block; }

/* reminders how-to + pepper schedule */
.howto { margin-top: 6px; }
.howto summary { font-size: 13px; padding: 2px 0; }
.howto div { font-size: 14px; line-height: 1.7; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-top: 6px; }
.pepper-rem { background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.toggle { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: 14px; white-space: nowrap; }
.toggle input { width: auto; }

/* v3: habits/journal/shoot */
.check.auto { cursor: default; font-size: 14px; border-style: dashed; color: var(--muted); }
.check.auto.on { color: #fff; border-style: solid; }
.item.optional .title { opacity: .85; }
.heat i.off { background: transparent; border: 1px dashed var(--line); }
.daypick { display: flex; gap: 6px; flex-wrap: wrap; }
.daypick label { margin: 0; }
.daypick input { display: none; }
.daypick span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); cursor: pointer; }
.daypick input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.scale { display: flex; gap: 8px; }
.scale label { margin: 0; flex: 1; }
.scale input { display: none; }
.scale span { display: grid; place-items: center; height: 44px; border-radius: 12px; border: 1px solid var(--line); font-size: 20px; cursor: pointer; color: var(--text); }
.scale input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.cta { border-color: var(--accent); }
h3 { font-size: 15px; margin: 14px 0 6px; }
ul.list { margin: 0; padding-inline-start: 18px; font-size: 14px; line-height: 1.7; }
details.entry { border-bottom: 1px solid var(--line); padding: 8px 0; }
details.entry summary { color: var(--text); }
details.entry p { margin: 6px 0; font-size: 14px; }
