:root {
  --primary: #ff8a7a;
  --primary-dark: #f2604e;
  --primary-soft: #ffe3dd;
  --bg: #fdf6f1;
  --card: #ffffff;
  --text: #4a3f3a;
  --text-sub: #9b8a82;
  --line: #f0e2da;
  --sym-none: #34a853;
  --sym-mild: #f9ab00;
  --sym-moderate: #fb8c00;
  --sym-severe: #e53935;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(120, 80, 60, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- ヘッダー ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, #ffa294, var(--primary-dark));
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 0;
  box-shadow: 0 2px 8px rgba(220, 90, 70, 0.3);
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.title-row h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 12px;
  font-size: 18px;
  padding: 6px 12px;
  color: #fff;
  cursor: pointer;
}

.child-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 12px;
}

.child-tabs:empty { padding: 6px 0; }

.child-tab {
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.child-tab .c-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c, #fff);
  border: 1.5px solid #fff;
}

.child-tab.active {
  background: #fff;
  color: var(--primary-dark);
  border-color: #fff;
}

/* ---------- メイン ---------- */
main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 12px 40px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

h2.section-title {
  font-size: 15px;
  margin: 0 0 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- カレンダー ---------- */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.month-nav .month-label {
  font-size: 18px;
  font-weight: 700;
}

.month-nav .nav-btns {
  display: flex;
  gap: 6px;
}

.nav-btn {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: none;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.weekday-row, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.weekday-row {
  margin-bottom: 4px;
}

.weekday-row span {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 600;
}

.weekday-row span:first-child { color: #e57373; }
.weekday-row span:last-child { color: #64b5f6; }

.cell {
  min-height: 56px;
  border-radius: 10px;
  border: none;
  background: transparent;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: inherit;
}

.cell.day {
  background: #fff;
  border: 1px solid var(--line);
  cursor: pointer;
}

.cell.day:active { background: var(--primary-soft); }

.cell.today {
  border: 2px solid var(--primary);
  background: var(--primary-soft);
}

.cell .num {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.cell.today .num { color: var(--primary-dark); }

.cell .marks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  max-width: 100%;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.sym-none { background: var(--sym-none); }
.sym-mild { background: var(--sym-mild); }
.sym-moderate { background: var(--sym-moderate); }
.sym-severe { background: var(--sym-severe); }

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-sub);
}

.cal-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------- 今日のサマリー ---------- */
.summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.summary-item:last-child { border-bottom: none; }

.a-name { font-weight: 700; font-size: 14px; }

.a-target {
  font-size: 12px;
  color: var(--text-sub);
}

.badge {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.badge.sym-none { background: var(--sym-none); }
.badge.sym-mild { background: var(--sym-mild); }
.badge.sym-moderate { background: var(--sym-moderate); }
.badge.sym-severe { background: var(--sym-severe); }

/* ---------- ボタン ---------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: #f1e7e1;
  color: var(--text);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.danger {
  background: #fdecea;
  color: #c62828;
}

.btn.small {
  padding: 7px 14px;
  font-size: 13px;
}

.btn.block {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.btn:active { opacity: 0.8; }

/* ---------- モーダル ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(70, 45, 35, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-body {
  background: var(--card);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  animation: slide-up 0.2s ease-out;
}

@keyframes slide-up {
  from { transform: translateY(30px); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-head h2 {
  font-size: 17px;
  margin: 0;
}

.close-btn {
  background: #f1e7e1;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

/* ---------- 記録リスト ---------- */
.rec-list { margin-bottom: 8px; }

.rec-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.rec-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rec-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
}

.rec-allergen {
  font-size: 12px;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 2px 10px;
}

.rec-food {
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

.rec-memo {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 4px;
  white-space: pre-wrap;
}

.rec-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.rec-actions .btn { padding: 5px 12px; font-size: 12px; }

.empty-msg {
  text-align: center;
  color: var(--text-sub);
  font-size: 13px;
  padding: 14px 0;
}

/* ---------- フォーム ---------- */
form .field { margin-bottom: 12px; }

form label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 4px;
}

input[type="text"], input[type="time"], select, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 16px;
  font-family: inherit;
  background: #fffdfb;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

textarea { resize: vertical; min-height: 64px; }

.target-hint {
  background: #fff7e6;
  border: 1px solid #ffe0a3;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.target-hint b { color: #b26a00; }

.symptom-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.sym-btn {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 9px 2px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-sub);
  cursor: pointer;
}

.sym-btn.selected[data-sym="none"] { background: var(--sym-none); border-color: var(--sym-none); color: #fff; }
.sym-btn.selected[data-sym="mild"] { background: var(--sym-mild); border-color: var(--sym-mild); color: #fff; }
.sym-btn.selected[data-sym="moderate"] { background: var(--sym-moderate); border-color: var(--sym-moderate); color: #fff; }
.sym-btn.selected[data-sym="severe"] { background: var(--sym-severe); border-color: var(--sym-severe); color: #fff; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.form-actions .btn { flex: 1; }

/* ---------- 色選択 ---------- */
.color-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
}

.swatch.selected {
  border-color: var(--text);
  transform: scale(1.1);
}

/* ---------- 設定画面 ---------- */
.child-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.child-card-head .c-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.child-card-head .c-name {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
}

.allergen-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.allergen-row:last-of-type { border-bottom: none; }

.allergen-info { flex: 1; min-width: 0; }

.allergen-info .a-note {
  font-size: 11px;
  color: var(--text-sub);
}

.settings-note {
  font-size: 12px;
  color: var(--text-sub);
  margin: 8px 0 0;
}

/* ---------- ようこそ画面 ---------- */
.welcome {
  text-align: center;
  padding: 40px 16px;
}

.welcome .big { font-size: 52px; }

.welcome h2 { font-size: 18px; margin: 12px 0 6px; }

.welcome p {
  font-size: 13px;
  color: var(--text-sub);
  margin: 0 0 20px;
}

@media (min-width: 480px) {
  .modal { align-items: center; }
  .modal-body { border-radius: 20px; }
  .cell { min-height: 64px; }
}
