:root {
  color-scheme: light;
  --bg: #f0f9fc;
  --card: #ffffff;
  --text: #37505c;
  --text-soft: #82a0ac;
  --accent: #4fa8cc;
  --accent-dark: #3b90b5;
  --accent-pale: #e2f3f9;
  --line: #dcedf4;
  --sun: #f2a65a;
  --sun-pale: #fdf1e3;
  --danger: #c0645e;
  --shadow: 0 2px 10px rgba(60, 120, 150, 0.08);
  --radius: 16px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ---------- ヘッダー・レイアウト ---------- */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 12px) 20px 10px;
  text-align: center;
}
.app-title { font-size: 18px; font-weight: 700; letter-spacing: 0.05em; }

main#view {
  padding: 4px 16px 110px;
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- タブバー ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1;
  background: none; border: none;
  font-family: inherit;
  font-size: 10px;
  color: var(--text-soft);
  padding: 8px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer;
}
.tabbar button.active { color: var(--accent-dark); font-weight: 700; }
.tab-icon { font-size: 20px; }

/* ---------- カード共通 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.section-title {
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 700;
  margin: 18px 4px 8px;
}

/* ---------- きょうのおたのしみ（ガチャ） ---------- */
.gacha-card { text-align: center; padding: 18px 16px; }
.gacha-title { font-size: 15px; font-weight: 700; color: var(--accent-dark); margin-bottom: 10px; }
.gacha-filters { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.gacha-filters .chip { font-size: 12px; padding: 5px 10px; }
.gacha-result {
  background: var(--sun-pale);
  border: 2px solid #f6d9b6;
  border-radius: 14px;
  padding: 14px 12px;
  margin-bottom: 12px;
}
.gacha-emoji { font-size: 34px; line-height: 1.2; }
.gacha-label { font-size: 18px; font-weight: 700; margin: 4px 0 2px; }
.gacha-hint { font-size: 13px; color: var(--text-soft); }
.gacha-empty {
  color: var(--text-soft);
  font-size: 14px;
  padding: 14px 8px 16px;
  line-height: 1.8;
}
.gacha-btns { display: flex; gap: 8px; }
.gacha-btns .btn-primary { flex: 1.4; margin-top: 0; }
.gacha-btns .btn-sub { flex: 1; margin-top: 0; }
.btn-draw {
  display: block; width: 100%;
  background: var(--sun);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 17px; font-weight: 700;
  padding: 15px;
  cursor: pointer;
}
.btn-draw:active { background: #e2953f; }

/* ---------- きょうの記録カード ---------- */
.today-card { text-align: center; padding: 20px 16px; }
.today-label { font-size: 13px; color: var(--accent-dark); font-weight: 700; }
.today-count { font-size: 44px; font-weight: 700; line-height: 1.3; }
.today-count small { font-size: 16px; font-weight: 700; margin-left: 2px; }
.today-note { font-size: 13px; color: var(--text-soft); }

/* きょうの記録チップ */
.done-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; justify-content: center; }
.done-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-pale);
  color: var(--accent-dark);
  border-radius: 99px;
  font-size: 12px; font-weight: 700;
  padding: 4px 6px 4px 12px;
}
.done-chip .undo {
  border: none; background: rgba(255,255,255,0.9);
  color: var(--text-soft);
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 12px; line-height: 20px;
  cursor: pointer;
}

/* ---------- おたのしみグループ（開閉式） ---------- */
.cat-card { padding: 0; overflow: hidden; }
.cat-head {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  border: none; background: none;
  font-family: inherit;
  font-size: 16px; font-weight: 700;
  color: var(--text);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
}
.cat-emoji { font-size: 22px; }
.cat-name { flex: 1; }
.cat-today {
  font-size: 12px; font-weight: 700;
  color: var(--accent-dark);
  background: var(--accent-pale);
  border-radius: 99px;
  padding: 2px 10px;
}
.cat-arrow { color: var(--text-soft); font-size: 13px; transition: transform 0.2s; }
.cat-card.open .cat-arrow { transform: rotate(90deg); }
.cat-body { padding: 0 14px 14px; }
.cat-note { font-size: 12px; color: var(--text-soft); margin: 0 2px 10px; }

/* おたのしみボタン */
.task-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.task-btn {
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 99px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.1s;
}
.task-btn:active { transform: scale(0.95); }
.task-btn.done {
  border-color: var(--accent);
  background: var(--accent-pale);
  color: var(--accent-dark);
  font-weight: 700;
}
.task-btn .times { font-size: 11px; margin-left: 4px; }

/* 自由入力ボタン */
.btn-custom {
  display: block; width: 100%;
  background: var(--card);
  border: 1.5px dashed var(--accent);
  color: var(--accent-dark);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px; font-weight: 700;
  padding: 14px;
  margin: 4px 0 14px;
  cursor: pointer;
}

/* ---------- カレンダー ---------- */
.total-card { text-align: center; padding: 20px 16px; }
.total-num { font-size: 34px; font-weight: 700; }
.total-num small { font-size: 15px; margin-left: 2px; }

.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 2px 8px;
}
.cal-nav button {
  border: none; background: var(--card);
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 15px; font-weight: 700;
  border-radius: 10px;
  padding: 6px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.cal-nav button:disabled { color: var(--line); cursor: default; }
.cal-month { font-size: 16px; font-weight: 700; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 12px 10px;
}
.cal-dow {
  text-align: center;
  font-size: 11px; font-weight: 700;
  color: var(--text-soft);
  padding-bottom: 2px;
}
.cal-dow.sun { color: #cf7a74; }
.cal-dow.sat { color: var(--accent); }
.cal-cell {
  border: none; background: none;
  font-family: inherit;
  border-radius: 12px;
  min-height: 52px;
  padding: 4px 0 2px;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  color: var(--text);
  cursor: pointer;
}
.cal-cell.blank { cursor: default; }
.cal-cell .d { font-size: 12px; line-height: 1.4; }
.cal-cell .stamp { font-size: 17px; line-height: 1.2; }
.cal-cell .stamp.none { color: transparent; }
.cal-cell.today .d {
  background: var(--accent);
  color: #fff;
  border-radius: 99px;
  width: 20px; height: 20px;
  line-height: 20px;
  font-weight: 700;
}
.cal-cell.selected { background: var(--accent-pale); }
.cal-count { font-size: 10px; color: var(--sun); font-weight: 700; line-height: 1; }

.day-head {
  display: flex; align-items: baseline; gap: 8px;
  margin: 18px 4px 8px;
}
.day-date { font-size: 14px; font-weight: 700; }
.day-count { font-size: 12px; color: var(--accent-dark); font-weight: 700; }
.rec-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.rec-row:last-child { border-bottom: none; }
.rec-emoji { font-size: 16px; }
.rec-label { flex: 1; word-break: break-word; }
.rec-del {
  border: none; background: none;
  color: var(--text-soft);
  font-size: 15px;
  padding: 4px 8px;
  cursor: pointer;
}
.empty-note {
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
  padding: 28px 12px;
  line-height: 1.9;
}

/* ---------- 入力まわり ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 6px;
}
input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  padding: 12px;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
::placeholder { color: #aec5cf; opacity: 1; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 99px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.chip.on {
  border-color: var(--accent);
  background: var(--accent-pale);
  color: var(--accent-dark);
  font-weight: 700;
}

.btn-primary {
  display: block; width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 17px; font-weight: 700;
  padding: 15px;
  margin-top: 4px;
  cursor: pointer;
}
.btn-primary:active { background: var(--accent-dark); }
.btn-ghost {
  display: block; width: 100%;
  background: none;
  border: none;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 15px;
  padding: 12px;
  margin-top: 4px;
  cursor: pointer;
}
.btn-danger {
  display: block; width: 100%;
  background: none;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  border-radius: 14px;
  font-family: inherit;
  font-size: 15px;
  padding: 12px;
  margin-top: 10px;
  cursor: pointer;
}
.btn-sub {
  display: block; width: 100%;
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  font-family: inherit;
  font-size: 15px; font-weight: 700;
  padding: 13px;
  margin-top: 10px;
  cursor: pointer;
}
.btn-sub:first-child { margin-top: 0; }

/* ---------- シート（下から出る画面） ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(55, 80, 92, 0.35);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 88vh;
  overflow-y: auto;
  max-width: 560px;
  margin: 0 auto;
}
.sheet h2 { font-size: 17px; text-align: center; margin: 4px 0 16px; }
.sheet-handle {
  width: 44px; height: 5px;
  border-radius: 99px;
  background: var(--line);
  margin: 4px auto 10px;
}

/* ---------- はじめて画面 ---------- */
.onboarding {
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top) + 60px) 24px 40px;
}
.onboarding-inner { max-width: 480px; margin: 0 auto; text-align: center; }
.onboarding-logo { font-size: 56px; }
.onboarding h1 { font-size: 22px; margin: 10px 0 14px; }
.onboarding-lead { font-size: 14px; color: var(--text-soft); margin-bottom: 26px; text-align: left; }
.onboarding-note { font-size: 12px; color: var(--text-soft); margin-top: 12px; }

/* ---------- せってい ---------- */
.settings-note { font-size: 13px; color: var(--text-soft); margin: 8px 4px 0; line-height: 1.8; }
.about-text { font-size: 14px; line-height: 1.9; }
.about-text a { color: var(--accent-dark); font-weight: 700; }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 120px);
  z-index: 50;
  background: var(--text);
  color: #fff;
  border-radius: 99px;
  padding: 10px 22px;
  font-size: 14px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

/* ---------- ねぎらいコメント ---------- */
.warm-pop {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 120px);
  transform: translateX(-50%) translateY(16px);
  z-index: 60;
  display: flex; align-items: flex-start; gap: 10px;
  width: min(86vw, 420px);
  background: #fcfeff;
  border: 2px solid #c3e2ef;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(60, 120, 150, 0.18);
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.warm-pop.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.warm-pop-icon { font-size: 20px; flex-shrink: 0; }
