:root {
  color-scheme: light;
  --bg: #fdf6ee;
  --card: #ffffff;
  --text: #4a3f35;
  --text-soft: #9a8b7d;
  --accent: #e8927c;
  --accent-dark: #d97a63;
  --line: #f0e4d7;
  --danger: #c0645e;
  --shadow: 0 2px 10px rgba(120, 90, 60, 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 140px;
  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; }

/* ---------- ＋ボタン ---------- */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom) + 76px);
  z-index: 21;
  width: 60px; height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 32px;
  line-height: 60px;
  box-shadow: 0 4px 14px rgba(217, 122, 99, 0.4);
  cursor: pointer;
}
.fab:active { transform: scale(0.94); }

/* ---------- カード共通 ---------- */
.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;
}

/* ---------- ホーム ---------- */
.memory-card { border: 2px solid var(--line); }
.memory-label { font-size: 12px; color: var(--accent-dark); font-weight: 700; margin-bottom: 6px; }
.big-record-btn {
  display: block; width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 18px; font-weight: 700;
  padding: 18px;
  margin: 6px 0 4px;
  box-shadow: 0 4px 14px rgba(217, 122, 99, 0.35);
  cursor: pointer;
}
.big-record-btn:active { transform: scale(0.98); }
.home-stats { text-align: center; color: var(--text-soft); font-size: 13px; margin: 10px 0 4px; }

/* ---------- 記録カード ---------- */
.entry-card { cursor: pointer; }
.entry-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-soft);
}
.entry-date { font-weight: 700; }
.badge {
  display: inline-block;
  border-radius: 99px;
  padding: 1px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.child-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700;
  border-radius: 99px;
  padding: 1px 10px;
  color: #fff;
}
.entry-body { white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.empty-note {
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
  padding: 28px 12px;
  line-height: 1.9;
}

/* ---------- チップ（選択ボタン） ---------- */
.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 16px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.chip.on {
  border-color: var(--accent);
  background: #fdeee8;
  color: var(--accent-dark);
  font-weight: 700;
}

/* ---------- 入力まわり ---------- */
.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"], input[type="date"], input[type="search"], textarea, select {
  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, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
::placeholder { color: #c8bbae; opacity: 1; }
textarea { resize: none; }

.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;
}

/* ---------- シート（下から出る画面） ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(74, 63, 53, 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;
}

/* ---------- カラー選択 ---------- */
.color-row { display: flex; gap: 10px; margin-top: 6px; }
.color-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
}
.color-dot.on { border-color: var(--text); }

/* ---------- はじめて画面 ---------- */
.onboarding {
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top) + 40px) 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; }
.onboarding-form {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: left;
}
.onboarding-form h2 { font-size: 15px; text-align: center; margin-bottom: 16px; }
.onboarding-note { font-size: 12px; color: var(--text-soft); text-align: center; margin-top: 12px; }

/* ---------- カレンダー ---------- */
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 4px 10px;
}
.cal-head button {
  border: none; background: var(--card);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 18px;
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.cal-title { font-weight: 700; font-size: 16px; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 8px;
}
.cal-dow { text-align: center; font-size: 11px; color: var(--text-soft); font-weight: 700; }
.cal-day {
  border: none; background: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  border-radius: 10px;
  padding: 6px 0 4px;
  min-height: 44px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.cal-day.today { background: #fdeee8; font-weight: 700; }
.cal-day.selected { outline: 2px solid var(--accent); }
.cal-day .dots { display: flex; gap: 2px; min-height: 6px; }
.cal-day .dot { width: 6px; height: 6px; border-radius: 50%; }

/* ---------- こどもページ ---------- */
.kid-card { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.kid-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.kid-info { flex: 1; }
.kid-name { font-weight: 700; font-size: 16px; }
.kid-sub { font-size: 12px; color: var(--text-soft); }
.kid-arrow { color: var(--text-soft); }
.age-group-title {
  font-size: 14px; font-weight: 700;
  color: var(--accent-dark);
  margin: 20px 4px 8px;
}
.back-btn {
  border: none; background: none;
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 14px; font-weight: 700;
  padding: 8px 4px;
  cursor: pointer;
}

/* ---------- せってい ---------- */
.settings-note { font-size: 13px; color: var(--text-soft); margin: 8px 4px 0; line-height: 1.8; }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 150px);
  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) + 150px);
  transform: translateX(-50%) translateY(16px);
  z-index: 60;
  display: flex; align-items: flex-start; gap: 10px;
  width: min(86vw, 420px);
  background: #fffdf9;
  border: 2px solid #f5d9c8;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(120, 90, 60, 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; }

/* ---------- 検索・フィルタ ---------- */
.filter-bar { margin: 6px 0 12px; }
.filter-bar .chip-row { margin-top: 8px; }
