:root {
  color-scheme: dark;
  --bg: #0f172a;
  --card: #1e293b;
  --line: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
}
[data-cat='baik'] { --c: #22c55e; }
[data-cat='perlu'] { --c: #38bdf8; }
[data-cat='buang'] { --c: #f97316; }
[data-cat='tidur'] { --c: #a78bfa; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
main { max-width: 560px; margin: 0 auto; padding: 16px; }
h2 { font-size: 18px; margin: 20px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
button, input, select, .filebtn { font: inherit; color: inherit; }
button, .filebtn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}
button:disabled { opacity: .35; cursor: default; }
.primary { background: #2563eb; border-color: #2563eb; }
.danger { color: #fca5a5; }
.link { background: none; border: 0; color: #60a5fa; padding: 4px; }
.muted { color: var(--muted); }
.warn { color: #fbbf24; font-size: 13px; }
.grow { flex: 1; text-align: left; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rowhead { display: flex; justify-content: space-between; align-items: end; }

.now {
  background: var(--card);
  border: 2px solid var(--c, var(--line));
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}
.nowname { font-size: 20px; font-weight: 600; }
.timer { font-size: 42px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c); }
.wake { width: 100%; margin-top: 12px; padding: 16px; font-size: 18px; font-weight: 600; background: #7c3aed; border-color: #7c3aed; }

.backdate { display: flex; gap: 6px; align-items: center; margin: 12px 0 8px; flex-wrap: wrap; }
.backdate button { padding: 4px 10px; font-size: 13px; white-space: nowrap; border-radius: 20px; }
.backdate .on { background: #2563eb; border-color: #2563eb; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.act {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 76px; justify-content: center; padding: 8px 4px; font-size: 13px;
  border-bottom: 3px solid var(--c);
}
.act:active { transform: scale(.96); }
.act.on { background: color-mix(in srgb, var(--c) 30%, var(--card)); border-color: var(--c); }
.ico { font-size: 24px; }

.daynav { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; }
.daynav h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--card); border-radius: 12px; padding: 10px; text-align: center; border-top: 3px solid var(--c); }
.stat strong { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }

.bar { margin-bottom: 10px; }
.barlabel { display: flex; justify-content: space-between; margin-bottom: 3px; }
.track { height: 8px; background: var(--card); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; background: var(--c); }

ul { list-style: none; margin: 0; padding: 0; }
.timeline li, .acts li { margin-bottom: 6px; }
.timeline button, .acts button { display: flex; gap: 10px; width: 100%; align-items: center; border-left: 4px solid var(--c); }
.time { font-size: 12px; color: var(--muted); min-width: 118px; text-align: left; }

.weekrow { display: grid; grid-template-columns: 64px 1fr; align-items: center; margin-bottom: 6px; }
.stack { display: flex; height: 18px; background: var(--card); border-radius: 5px; overflow: hidden; }
.stack div, .legend span::before { background: var(--c); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; margin-top: 8px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

.acts { margin-bottom: 10px; }

nav {
  position: fixed; inset: auto 0 0 0; display: flex; gap: 6px; justify-content: center;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
}
nav button { flex: 1; max-width: 180px; }
nav .on { background: #2563eb; border-color: #2563eb; }

.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom));
  max-width: 536px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #f1f5f9; color: #0f172a; border-radius: 12px; padding: 10px 14px;
}
.toast button { background: #0f172a; color: #f1f5f9; padding: 5px 12px; }

dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; width: min(92vw, 400px); }
dialog::backdrop { background: rgb(0 0 0 / .6); }
dialog h3 { margin-top: 0; }
dialog label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
dialog input, dialog select {
  display: block; width: 100%; margin-top: 3px; padding: 9px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font-size: 16px;
}
