:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e7eaf0;
  --muted: #9aa3b2;
  --accent: #4ade80;
  --accent-dim: #1c3a2a;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 76px;
  padding-top: env(safe-area-inset-top);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.topbar h1 { font-size: 22px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  width: 38px; height: 34px; font-size: 16px; cursor: pointer;
}
.icon-btn.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.date-picker {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 14px;
}

main { padding: 4px 16px 24px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }

.check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}
.check.on { border-color: var(--accent); background: var(--accent-dim); }
.check .box {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--muted); flex: 0 0 auto;
  display: grid; place-items: center; font-size: 14px; color: var(--bg);
}
.check.on .box { background: var(--accent); border-color: var(--accent); }
.check .box::after { content: "✓"; opacity: 0; }
.check.on .box::after { opacity: 1; }
.check .label { flex: 1; }
.check .sub { display: block; font-size: 12px; color: var(--muted); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.feedback { border-color: var(--accent); }
.feedback .body { white-space: pre-wrap; line-height: 1.5; font-size: 14px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 0; }

.row { display: flex; gap: 10px; align-items: center; }
input[type="number"], textarea, input[type="text"] {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; font-size: 16px; width: 100%; font-family: inherit;
}
textarea { min-height: 70px; resize: vertical; }
button.btn {
  background: var(--accent); color: #06210f; border: none;
  border-radius: 10px; padding: 12px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
}
button.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }

.list-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; margin-bottom: 8px;
}
.list-item .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.list-item pre { white-space: pre-wrap; margin: 0; font-family: inherit; font-size: 13px; }

.macros { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 6px; }
.macros b { color: var(--text); }

.trend { width: 100%; height: 120px; }
.stat-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 30;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px;
}
.modal h2 { margin: 0 0 8px; font-size: 17px; }
.modal-note { color: var(--muted); font-size: 13px; margin: 0 0 14px; line-height: 1.45; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.modal-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  background: none; border: none; color: var(--muted);
  padding: 14px 0; font-size: 12px; cursor: pointer;
}
.tab.active { color: var(--accent); }
