:root {
  --bg: #fff7fb;
  --bg-2: #f1fbff;
  --card: rgba(255, 255, 255, 0.88);
  --text: #2b2335;
  --muted: #716980;
  --pink: #ff92c2;
  --pink-2: #ffe0ef;
  --blue: #8ed6ff;
  --green: #bdf3c4;
  --yellow: #fff2a8;
  --purple: #c9b7ff;
  --red: #ffb4a8;
  --shadow: 0 18px 50px rgba(123, 82, 139, 0.16);
  --border: rgba(107, 86, 120, 0.12);
  --radius: 26px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255,146,194,.32), transparent 34rem),
    radial-gradient(circle at top right, rgba(142,214,255,.38), transparent 30rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
textarea { resize: vertical; }

#app { min-height: 100vh; }

.setup-missing, .login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.cloud-card, .login-card, .card {
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
}

.cloud-card { max-width: 640px; padding: 28px; }
.logo-bubble {
  width: 74px; height: 74px;
  border-radius: 24px;
  display: grid; place-items: center;
  font-size: 36px;
  background: linear-gradient(135deg, var(--pink-2), #e4f7ff);
  box-shadow: inset 0 -8px 18px rgba(255,255,255,.62);
}

.login-card {
  width: min(940px, 100%);
  padding: clamp(18px, 4vw, 34px);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "✨";
  position: absolute;
  right: 20px; top: 18px;
  font-size: 44px;
  opacity: .65;
}

.hero-title {
  font-size: clamp(34px, 7vw, 64px);
  line-height: .95;
  margin: 10px 0 8px;
  letter-spacing: -1.8px;
}
.hero-sub { color: var(--muted); margin: 0 0 22px; font-size: 17px; }

.login-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.user-tile {
  min-height: 142px;
  border-radius: 24px;
  background: #fff;
  border: 2px solid transparent;
  padding: 14px 10px;
  color: var(--text);
  box-shadow: 0 12px 24px rgba(68, 55, 83, .09);
  transition: transform .16s ease, border .16s ease;
}
.user-tile.selected { border-color: var(--pink); transform: translateY(-3px) scale(1.02); }
.user-avatar { font-size: 44px; display: block; margin-bottom: 8px; }
.user-name { font-weight: 900; font-size: 18px; }
.user-role { color: var(--muted); font-size: 12px; margin-top: 4px; }

.login-form {
  display: grid;
  grid-template-columns: 1fr 150px auto;
  gap: 10px;
  align-items: center;
}
.field, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.95);
  border-radius: 18px;
  padding: 14px 15px;
  outline: none;
  color: var(--text);
}
.field:focus, .select:focus, .textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 146, 194, .18); }
.primary, .secondary, .ghost, .danger, .success, .tiny-btn {
  border-radius: 18px;
  padding: 13px 16px;
  font-weight: 900;
  min-height: 46px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.primary { background: linear-gradient(135deg, var(--pink), #ffb8d6); color: #fff; box-shadow: 0 12px 28px rgba(255, 120, 180, .3); }
.secondary { background: #eef8ff; color: #24506d; }
.ghost { background: rgba(255,255,255,.7); color: var(--text); border: 1px solid var(--border); }
.success { background: var(--green); color: #1a5a2b; }
.danger { background: #ffe5e0; color: #9a2d1b; }
.tiny-btn { min-height: 36px; padding: 8px 10px; border-radius: 14px; font-size: 13px; }

.app-shell { min-height: 100vh; padding-bottom: 88px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  background: rgba(255,247,251,.88);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; flex: 1;
}
.brand-icon { font-size: 32px; }
.brand h1 { margin: 0; font-size: 20px; line-height: 1; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.child-select { width: 130px; padding: 10px 12px; border-radius: 16px; }

.content { width: min(1120px, 100%); margin: 0 auto; padding: 18px 14px 32px; }
.greeting {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.greeting h2 { font-size: clamp(26px, 6vw, 44px); margin: 0; letter-spacing: -.8px; }
.greeting p { margin: 4px 0 0; color: var(--muted); }
.date-picker { max-width: 180px; }

.bottom-nav {
  position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(820px, calc(100% - 18px));
  background: rgba(255,255,255,.9);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(79, 57, 97, .18);
  border-radius: 24px;
  display: grid;
  gap: 4px;
  padding: 6px;
  backdrop-filter: blur(18px);
}
.bottom-nav.parent { grid-template-columns: repeat(8, 1fr); }
.bottom-nav.kid { grid-template-columns: repeat(6, 1fr); }
.nav-btn {
  background: transparent;
  color: var(--muted);
  border-radius: 18px;
  padding: 8px 4px;
  min-height: 54px;
  font-weight: 900;
  font-size: 11px;
}
.nav-btn span { display: block; font-size: 20px; margin-bottom: 3px; }
.nav-btn.active { background: var(--pink-2); color: #8c3460; }

.stats-grid, .dashboard-grid, .reward-grid, .meal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.stat, .mini-card {
  border-radius: 22px;
  background: rgba(255,255,255,.85);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: 0 10px 26px rgba(92, 71, 109, .08);
}
.stat b { display: block; font-size: 28px; }
.stat span { color: var(--muted); font-size: 13px; }

.task-list { display: grid; gap: 12px; }
.task-card { padding: 16px; overflow: hidden; }
.task-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.task-time { font-weight: 900; color: #8c3460; background: var(--pink-2); border-radius: 999px; padding: 6px 10px; white-space: nowrap; }
.task-title { font-size: 20px; font-weight: 950; margin: 0 0 4px; }
.task-text { color: var(--muted); margin: 6px 0; line-height: 1.45; }
.task-kid { background: #f5fbff; border-radius: 18px; padding: 12px; margin: 10px 0; border: 1px solid rgba(54, 143, 192, .12); }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.status-pill { font-size: 12px; font-weight: 900; border-radius: 999px; padding: 6px 9px; background: #f3eef7; color: #6c5578; }
.status-done { background: #dffadc; color: #207036; }
.status-need_help { background: #ffe5e0; color: #a23d26; }
.status-started { background: #e6f5ff; color: #246484; }
.status-skipped { background: #f1edf4; color: #6b6270; }
.comment-row { margin-top: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.mood-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.mood { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 7px 10px; }
.mood.active { background: var(--yellow); border-color: #eedc68; }

.progress-ring {
  width: 74px; height: 74px;
  border-radius: 50%;
  background: conic-gradient(var(--pink) var(--progress), #f0e7f4 0);
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.progress-ring::after {
  content: attr(data-label);
  width: 54px; height: 54px;
  border-radius: 50%;
  background: #fff;
  display: grid; place-items: center;
  font-weight: 950;
  font-size: 14px;
}

.dashboard-card { padding: 18px; }
.dashboard-card h3 { margin: 0 0 4px; font-size: 24px; }
.dashboard-card .avatar-big { font-size: 44px; }

.calendar-wrap { padding: 14px; }
.calendar-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.weekday { color: var(--muted); font-size: 12px; font-weight: 900; text-align: center; }
.day {
  min-height: 74px;
  border-radius: 18px;
  background: rgba(255,255,255,.8);
  border: 1px solid var(--border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.day.empty { opacity: .35; }
.day-num { font-weight: 950; }
.day.good { background: #edffef; }
.day.ok { background: #fff9d3; }
.day.low { background: #ffece8; }
.dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); display: inline-block; }
.dot.request { background: var(--purple); }
.dot.help { background: var(--red); }
.day small { color: var(--muted); font-size: 11px; }

.list { display: grid; gap: 10px; }
.request-item, .claim-item, .note-item, .ledger-item, .routine-row {
  background: rgba(255,255,255,.85);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 13px;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-weight: 900; font-size: 12px; padding: 5px 8px; border-radius: 999px; background: #f1eef7; color: #66506f; }
.badge.pending { background: var(--yellow); }
.badge.approved, .badge.applied_once, .badge.applied_permanently { background: var(--green); }
.badge.rejected { background: #ffe5e0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-grid.full { grid-template-columns: 1fr; }
.section-title { font-size: 22px; margin: 20px 0 10px; }
.help-text { color: var(--muted); font-size: 13px; }
.error { color: #a32929; background: #ffe8e8; padding: 10px; border-radius: 16px; margin-top: 10px; }
.success-msg { color: #236d36; background: #e6ffe8; padding: 10px; border-radius: 16px; margin-top: 10px; }
.loading { padding: 24px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

.routine-row details { margin-top: 10px; }
.routine-row summary { cursor: pointer; font-weight: 900; }
.routine-editor { margin-top: 12px; display: grid; gap: 10px; }

@media (max-width: 820px) {
  .login-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-form { grid-template-columns: 1fr; }
  .stats-grid, .dashboard-grid, .reward-grid, .meal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .greeting { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .bottom-nav.parent { display: flex; overflow-x: auto; }
  .bottom-nav.parent .nav-btn { min-width: 70px; }
}

@media (max-width: 520px) {
  .content { padding-left: 10px; padding-right: 10px; }
  .task-head { align-items: flex-start; }
  .task-time { font-size: 12px; }
  .comment-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .calendar-grid { gap: 4px; }
  .day { min-height: 66px; padding: 6px; border-radius: 14px; }
  .day small { font-size: 10px; }
  .topbar { gap: 6px; }
  .brand h1 { font-size: 17px; }
  .child-select { width: 108px; }
}


/* iPhone app-like install/open link */
.install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 18px;
  padding: 14px;
  border-radius: 22px;
  background: linear-gradient(135deg, #fff, #eef8ff);
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(92, 71, 109, .08);
}
.install-banner p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.35; }
.install-button { text-decoration: none; white-space: nowrap; }
.install-page .logo-bubble { overflow: hidden; }
.install-page .logo-bubble img { width: 100%; height: 100%; display: block; border-radius: 24px; }
.install-hero-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.big-link { text-decoration: none; min-height: 56px; font-size: 16px; }
.install-steps {
  margin-top: 14px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255,255,255,.82);
  border: 1px solid var(--border);
}
.install-steps h2 { margin: 0 0 8px; font-size: 20px; }
.install-steps ol { margin: 0; padding-left: 22px; color: var(--text); }
.install-steps li { margin: 8px 0; }
.install-steps.vi { background: #f5fbff; }
@media (max-width: 520px) {
  .install-banner { align-items: stretch; flex-direction: column; }
  .install-button { width: 100%; }
  .install-hero-card { grid-template-columns: 1fr; }
}


.meal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.meal-card { padding: 16px; }
.food-pref-list { margin-top: 10px; }
.badge.like, .badge.love { background: #dffadc; color: #207036; }
.badge.dislike { background: #ffe5e0; color: #9a2d1b; }
.badge.want_to_try, .badge.want { background: #fff7d3; color: #6d5523; }

@media (max-width: 620px) {
  .meal-grid { grid-template-columns: 1fr; }
}

/* v1.4 management additions */
.bottom-nav.parent { grid-template-columns: repeat(11, 1fr); }
.bottom-nav.kid { grid-template-columns: repeat(8, 1fr); }
.weekly-grid, .phone-grid, .report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.day-meals { padding: 14px; }
.day-meals.selected { outline: 3px solid rgba(255,146,194,.45); }
.mini-meal-list { display: grid; gap: 8px; margin-top: 10px; }
.mini-meal { padding: 9px 10px; border-radius: 15px; background: #f8fcff; border: 1px solid rgba(54,143,192,.12); font-size: 13px; }
.checkline { display: inline-flex; align-items: center; gap: 8px; margin: 8px 12px 0 0; font-weight: 800; color: var(--muted); }
.shopping-card { margin-top: 10px; }
.shopping-list { margin-top: 12px; }
.shopping-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 16px; background: rgba(255,255,255,.86); border: 1px solid var(--border); }
.shopping-item.done { opacity: .62; text-decoration: line-through; }
.phone-card { padding: 16px; }
.board-post { border-left: 6px solid var(--pink-2); }
.report-card { padding: 18px; }
.report-card h4 { margin: 14px 0 8px; }
.streak-list { display: flex; flex-wrap: wrap; gap: 8px; }
.streak-pill { display: inline-flex; align-items: center; gap: 5px; padding: 8px 10px; border-radius: 999px; background: #fff7d3; font-weight: 850; color: #6d5523; font-size: 13px; }
.badge.open { background: #fff7d3; color: #6d5523; }
.badge.done { background: var(--green); color: #207036; }
@media (max-width: 820px) {
  .bottom-nav.parent, .bottom-nav.kid { display: flex; overflow-x: auto; justify-content: flex-start; }
  .bottom-nav .nav-btn { min-width: 72px; }
  .weekly-grid, .phone-grid, .report-grid { grid-template-columns: 1fr; }
}
