:root {
  --bg: #f4f5f4;
  --card: #ffffff;
  --text: #1c1f1e;
  --muted: #6b716f;
  --line: #e3e6e4;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #ccebe7;
  --hijau-bg: #d9f2e3; --hijau: #17633a;
  --kuning-bg: #fbedc6; --kuning: #7a5300;
  --merah-bg: #fbdcdc; --merah: #9b2424;
  --netral-bg: #eceeed; --netral: #5b6260;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121514;
    --card: #1c201f;
    --text: #e9ecea;
    --muted: #9aa19e;
    --line: #2e3432;
    --accent: #2bb3a5;
    --accent-text: #06201d;
    --accent-soft: #18413c;
    --hijau-bg: #173d27; --hijau: #8ee0ae;
    --kuning-bg: #45360f; --kuning: #f3cf6e;
    --merah-bg: #4a1d1d; --merah: #f4a3a3;
    --netral-bg: #272c2b; --netral: #a9b0ad;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.has-nav { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px 20px;
}
h1 { font-size: 22px; font-weight: 600; margin: 4px 0 12px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
h2.section { margin: 22px 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ic { flex-shrink: 0; }
code { background: var(--netral-bg); padding: 1px 5px; border-radius: 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary h2 { margin: 0; }
details.card[open] > summary { margin-bottom: 12px; }
summary::-webkit-details-marker { display: none; }

/* Form */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label small { display: block; margin-top: 4px; font-size: 12px; }
input, select {
  display: block; width: 100%;
  margin-top: 4px;
  padding: 11px 12px;
  font: inherit; font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
label.check input { width: auto; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px;
  font: inherit; font-weight: 600;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-danger { color: var(--merah); border-color: var(--merah-bg); }
.btn-ghost-danger { color: var(--merah); background: none; border: none; }
.btn-sm { padding: 7px 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline input { margin: 0; flex: 1; min-width: 0; }
.icon-btn {
  display: inline-flex; padding: 8px; border-radius: 10px;
  color: var(--text); background: var(--card); border: 1px solid var(--line);
}

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.flash-ok { background: var(--hijau-bg); color: var(--hijau); }
.flash-err { background: var(--merah-bg); color: var(--merah); }
.flash-warn { background: var(--kuning-bg); color: var(--kuning); }

.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; vertical-align: 1px; }
.pill-hijau { background: var(--hijau-bg); color: var(--hijau); }
.pill-kuning { background: var(--kuning-bg); color: var(--kuning); }
.pill-merah { background: var(--merah-bg); color: var(--merah); }
.pill-netral { background: var(--netral-bg); color: var(--netral); }
.c-hijau { color: var(--hijau); }
.c-kuning { color: var(--kuning); }
.c-merah { color: var(--merah); }
.c-netral { color: var(--muted); }

/* Auth */
.auth { max-width: 380px; margin: 6vh auto 0; }
.auth h1 { text-align: center; margin-bottom: 2px; }
.auth > p.muted:first-of-type { text-align: center; margin-top: 0; }
.auth .btn-primary { width: 100%; }
.logo { display: block; width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 10px; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.topbar h1 { margin: 0; text-align: center; flex: 1; }

/* Ringkasan atas kalender */
.summary {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px;
  color: inherit; text-decoration: none;
}
.summary .right { text-align: right; }
.big { font-size: 22px; font-weight: 700; line-height: 1.2; }
.big small { font-size: 13px; font-weight: 500; color: var(--muted); }

/* Kalender */
.cal-head, .cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-head { margin-bottom: 5px; }
.cal-head span { text-align: center; font-size: 12px; color: var(--muted); }
.day {
  aspect-ratio: 1 / 1.15;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  line-height: 1.15;
}
.day b { font-size: 14px; font-weight: 600; }
.day i { font-style: normal; font-size: 10.5px; font-weight: 600; margin-top: 2px; }
.day.future { opacity: 0.45; }
.day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.d-hijau { background: var(--hijau-bg); color: var(--hijau); }
.d-kuning { background: var(--kuning-bg); color: var(--kuning); }
.d-merah { background: var(--merah-bg); color: var(--merah); }
.d-ada { background: var(--netral-bg); color: var(--netral); }
.d-kosong { background: var(--card); border: 1px dashed var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin: 14px 0 4px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 4px; }

/* Input berat */
.date-pick { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.date-pick input { width: auto; margin: 0; padding: 8px 10px; }
.scale { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0 14px; }
.step {
  width: 52px; height: 52px; flex-shrink: 0;
  font-size: 26px; line-height: 1;
  border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); cursor: pointer;
}
.step:active { background: var(--accent-soft); }
.scale-val { display: flex; align-items: baseline; justify-content: center; gap: 4px; min-width: 0; }
.scale-val input {
  width: 4.2ch; padding: 0; margin: 0;
  font-size: 44px; font-weight: 700; text-align: center;
  background: none; border: none; border-bottom: 2px solid var(--line); border-radius: 0;
}
.scale-val input:focus { border-color: var(--accent); }
.scale-val span { color: var(--muted); }

dl.kv { margin: 0 0 14px; }
dl.kv div { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
dl.kv div:first-child { border-top: none; }
dl.kv dt { color: var(--muted); font-size: 14px; }
dl.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* Target */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.seg label { margin: 0; }
.seg input { display: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.seg input:checked + span { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.preview { background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }

/* List */
.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.row.static { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.row[open] summary .ic { transform: rotate(90deg); }
.row-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Progres */
.bar { height: 12px; background: var(--netral-bg); border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.bar div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 17px; }
.chart-box { position: relative; height: 240px; }

/* Navigasi bawah */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav a {
  flex: 1; max-width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; font-size: 11px; color: var(--muted); text-decoration: none;
}
.nav a.on { color: var(--accent); font-weight: 600; }
