:root {
  --bg: #FFF8F0; --card: #ffffff; --accent: #FF922B; --accent-dark: #E8590C;
  --text: #333333; --muted: #999999; --line: #f0e0d0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; } /* display指定を持つ要素でもhidden属性を必ず効かせる */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
header {
  position: sticky; top: 0; z-index: 10;
  background: var(--accent); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; justify-content: space-between; align-items: center;
}
header h1 { font-size: 16px; }
#points-badge { background: #fff; color: var(--accent-dark); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 14px; }
main { padding: 12px; max-width: 480px; margin: 0 auto; }
.card { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
h2 { font-size: 15px; margin-bottom: 8px; }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 10px; }
#day-detail { margin-top: 10px; }
#dd-view { font-size: 14px; margin-bottom: 8px; white-space: pre-wrap; }
#dd-view.empty { color: var(--muted); }

.summary { display: flex; gap: 8px; margin-bottom: 4px; }
.summary .card { flex: 1; text-align: center; padding: 10px 4px; margin-bottom: 8px; }
.label { font-size: 11px; color: var(--muted); }
.value { font-size: 20px; font-weight: 700; color: var(--accent-dark); }

.month-nav { display: flex; justify-content: space-between; align-items: center; margin: 6px 2px 8px; }
.month-nav button { border: none; background: var(--card); border-radius: 8px; padding: 6px 14px; font-size: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
#month-label { font-weight: 700; }

#cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-w { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; border: none; border-radius: 10px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.05);
  position: relative;
}
.cal-day.selected { background: #FFE8D0; }
.cal-day.has-note::after {
  content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent-dark);
}
.cal-day .num { line-height: 1.2; }
.cal-day .stamp { font-size: 20px; line-height: 1; min-height: 22px; animation: pop .25s ease; }
.cal-day.today { outline: 2px solid var(--accent); }
.cal-day.future { opacity: .35; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: none; background: none; padding: 8px 0 6px;
  font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar button .icon { font-size: 22px; }
.tabbar button.active { color: var(--accent-dark); font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: rgba(50,40,30,.92); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 20;
  white-space: nowrap; opacity: 0; transition: opacity .2s;
}
#toast.show { opacity: 1; }

.reward { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); list-style: none; }
.r-emoji { font-size: 24px; }
.r-name { flex: 1; font-size: 14px; word-break: break-all; }
.r-cost { font-weight: 700; color: var(--accent-dark); font-size: 13px; white-space: nowrap; }
.reward button { border: none; border-radius: 8px; padding: 8px 10px; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; }
.reward button:disabled { background: #ddd; color: #999; }
.reward .icon-btn { background: none; color: inherit; font-size: 15px; padding: 8px 2px; }

.stack { display: flex; flex-direction: column; gap: 8px; }
.stack input { border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 16px; background: #fff; }
.stack label { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.stack label input { width: 90px; }
.row { display: flex; gap: 8px; align-items: center; }
.btn { border: none; border-radius: 10px; padding: 12px; background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; }
.btn.ghost { background: none; color: var(--muted); }
.btn.full { width: 100%; margin-top: 10px; }
.btn.grow { flex: 1; }

#history-list { list-style: none; font-size: 13px; max-height: 300px; overflow-y: auto; }
#history-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
#history-list li.minus { color: var(--accent-dark); }
