:root {
  --indigo: #4f46e5;
  --indigo-dark: #4338ca;
  --kushi: #10b981;   /* green */
  --sunny: #ec4899;   /* pink */
  --both: #3b82f6;    /* blue (distinct) */
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.4;
}

.app-header {
  background: var(--indigo);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 18px) 20px 18px;
  text-align: center;
}
.app-header h1 { margin: 0; font-size: 22px; font-weight: 700; }
.app-header .sub { margin: 4px 0 0; font-size: 14px; opacity: 0.9; }

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

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.label { display: block; font-weight: 600; margin-bottom: 8px; }

textarea, input[type="text"], input[type="date"], input[type="time"], select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;   /* >=16px stops iOS zoom-on-focus */
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
#msg { min-height: 140px; resize: vertical; }

.row { display: flex; gap: 10px; margin-top: 12px; }
.btn {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--indigo); color: #fff; }
.btn.primary:active { background: var(--indigo-dark); }
.btn.ghost { background: #eef2ff; color: var(--indigo); }
.btn:disabled { opacity: 0.5; }

.status { margin: 10px 0 0; font-size: 14px; color: var(--muted); min-height: 18px; }
.status.error { color: #dc2626; }

.section-title { margin: 4px 0 2px; font-size: 18px; }
.hint { margin: 0 0 12px; font-size: 13px; color: var(--muted); }

.event {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 14px;
  border-left: 6px solid var(--both);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.event[data-child="Kushi"] { border-left-color: var(--kushi); }
.event[data-child="Sunny"] { border-left-color: var(--sunny); }
.event[data-child="Both"]  { border-left-color: var(--both); }
.event[data-confirmed="false"] { opacity: 0.5; }

.event-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.child-tag { width: auto; flex: 1; font-weight: 600; }
.confirm-toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.confirm-box { width: 20px; height: 20px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.ev-notes { min-height: 54px; resize: vertical; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0 calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.app-footer { text-align: center; padding: 20px; font-size: 13px; color: var(--muted); }
.hidden { display: none !important; }

.done-card { text-align: center; }
.done-check {
  width: 64px; height: 64px; line-height: 64px;
  margin: 4px auto 10px;
  border-radius: 50%;
  background: var(--both); color: #fff;
  font-size: 34px; font-weight: 700;
}
.done-card h2 { margin: 0 0 6px; font-size: 20px; }
.done-card .row { margin-top: 10px; }

/* Upcoming list */
.upcoming-head { display: flex; align-items: center; justify-content: space-between; }
.linkbtn { background: none; border: none; color: var(--indigo); font-size: 14px; font-weight: 600; cursor: pointer; padding: 4px; }
.filters { display: flex; gap: 8px; margin: 8px 0 12px; }
.chip {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 999px; padding: 7px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }

.up-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 10px;
}
.up-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--both); flex: 0 0 auto; }
.up-item[data-child="Kushi"] .up-dot { background: var(--kushi); }
.up-item[data-child="Sunny"] .up-dot { background: var(--sunny); }
.up-main { flex: 1; min-width: 0; }
.up-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-when { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-child { font-size: 12px; color: var(--muted); font-weight: 600; flex: 0 0 auto; }
.up-edit {
  border: none; background: #e0e7ff; color: #4f46e5;
  width: 44px; height: 44px; border-radius: 12px; font-size: 20px; line-height: 1;
  cursor: pointer; flex: 0 0 auto; margin-right: 8px;
  display: flex; align-items: center; justify-content: center;
}
.up-edit:active { background: #c7d2fe; }
.up-del {
  border: none; background: #fee2e2; color: #dc2626;
  width: 44px; height: 44px; border-radius: 12px; font-size: 24px; line-height: 1;
  cursor: pointer; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.up-del:active { background: #fecaca; }

/* Edit modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000;
}
.modal {
  background: #fff; border-radius: 16px; padding: 18px; width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 12px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.modal input, .modal select, .modal textarea { margin-top: 4px; }
.modal .chkline { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }
.modal .chkline input { width: 20px; height: 20px; margin: 0; }
.modal textarea { min-height: 54px; }

/* View toggle */
.viewtoggle { display: flex; gap: 6px; background: #eef2ff; padding: 4px; border-radius: 12px; margin: 4px 0 12px; }
.vtab { flex: 1; border: none; background: transparent; padding: 10px; border-radius: 9px; font-size: 15px; font-weight: 600; color: var(--indigo); cursor: pointer; }
.vtab.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 700; }
.cal-nav { border: none; background: #eef2ff; color: var(--indigo); width: 36px; height: 36px; border-radius: 10px; font-size: 20px; cursor: pointer; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 10px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 6px; position: relative; cursor: pointer; font-size: 14px;
}
.cal-cell.empty { background: transparent; box-shadow: none; cursor: default; }
.cal-cell.today { outline: 2px solid var(--indigo); }
.cal-cell.selected { background: #eef2ff; }
.cal-num { font-weight: 600; }
.cal-dots { display: flex; gap: 3px; margin-top: 3px; flex-wrap: wrap; justify-content: center; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--both); display: inline-block; }
.cal-dot.kushi { background: var(--kushi); }
.cal-dot.sunny { background: var(--sunny); }
.cal-dot.both { background: var(--both); }

.cal-detail-head { font-weight: 700; margin: 16px 0 8px; }
.cal-detail-item { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 10px 12px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); margin-bottom: 8px; }
.cal-detail-item .cal-dot { width: 10px; height: 10px; }
.cdi-main { flex: 1; min-width: 0; font-size: 14px; }
.cdi-child { font-size: 12px; color: var(--muted); font-weight: 600; }
