/* ── StarJar styles ─────────────────────────────────────────────── */
:root {
  --bg: #f4f2ff;
  --bg2: #eaf6ff;
  --card: #ffffff;
  --ink: #2d2a45;
  --ink-soft: #6f6b8f;
  --brand: #6c5ce7;
  --brand-dark: #5546d6;
  --sun: #ffc531;
  --mint: #00c896;
  --coral: #ff7675;
  --sky: #4aa8ff;
  --pink: #fd79a8;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(80, 70, 160, 0.12);
  --shadow-soft: 0 4px 14px rgba(80, 70, 160, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 600px at 85% -10%, #ffe9f3 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 20%, #e2f4ff 0%, transparent 55%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
}

#app { max-width: 960px; margin: 0 auto; padding: 20px 16px 90px; }

h1, h2, h3 { margin: 0 0 8px; font-weight: 900; }
p { line-height: 1.5; }
button { font-family: inherit; }

/* ── Generic UI ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px;
  animation: pop-in .35s cubic-bezier(.2,.9,.3,1.2) both;
}

.btn {
  border: none;
  border-radius: 16px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 0 var(--brand-dark);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--brand-dark); }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 12px; }
.btn.ghost { background: #edeafd; color: var(--brand-dark); box-shadow: 0 4px 0 #d8d2f7; }
.btn.mint { background: var(--mint); box-shadow: 0 4px 0 #00a67d; }
.btn.coral { background: var(--coral); box-shadow: 0 4px 0 #e05a59; }
.btn.sun { background: var(--sun); color: #6b4c00; box-shadow: 0 4px 0 #dfa714; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.input, select.input {
  width: 100%;
  border: 2px solid #e4e0f5;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: #fbfaff;
  outline: none;
  transition: border-color .15s ease;
}
.input:focus { border-color: var(--brand); }
label.field { display: block; font-weight: 800; font-size: 13px; color: var(--ink-soft); margin: 12px 0 4px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f1eeff; color: var(--brand-dark);
  border-radius: 999px; padding: 4px 12px;
  font-size: 13px; font-weight: 800;
}
.chip.gold { background: #fff3d1; color: #8a6100; }
.chip.green { background: #d9f7ec; color: #007a5c; }
.chip.red { background: #ffe3e3; color: #c0392b; }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.logo { font-size: 24px; font-weight: 900; letter-spacing: -.5px; }
.logo .star { display: inline-block; animation: twinkle 2.4s ease-in-out infinite; }

/* ── Profile picker ── */
.profiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.profile-card {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 26px 14px;
  text-align: center;
  cursor: pointer;
  transition: transform .18s cubic-bezier(.2,.9,.3,1.4), box-shadow .18s ease;
  animation: pop-in .4s cubic-bezier(.2,.9,.3,1.2) both;
}
.profile-card:nth-child(2) { animation-delay: .07s; }
.profile-card:nth-child(3) { animation-delay: .14s; }
.profile-card:nth-child(4) { animation-delay: .21s; }
.profile-card:hover { transform: translateY(-6px) scale(1.03); box-shadow: var(--shadow); }
.avatar {
  width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; margin: 0 auto 10px;
}
.profile-card .name { font-weight: 900; font-size: 18px; }
.profile-card .role { font-size: 13px; color: var(--ink-soft); font-weight: 700; }

/* ── Child home ── */
.hero {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  background: linear-gradient(120deg, var(--brand) 0%, #8e7bff 60%, #b3a4ff 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.hero h2 { font-size: 24px; margin: 0; }
.hero .sub { opacity: .9; font-weight: 700; font-size: 14px; }
.token-jar {
  background: rgba(255,255,255,.18);
  border-radius: 18px;
  padding: 12px 18px;
  text-align: center;
  backdrop-filter: blur(4px);
  animation: float 3.5s ease-in-out infinite;
}
.token-jar .count { font-size: 30px; font-weight: 900; }
.token-jar .label { font-size: 12px; font-weight: 800; opacity: .9; }

.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 26px 0 12px; font-size: 19px; font-weight: 900;
}

.task-list { display: flex; flex-direction: column; gap: 12px; }
.task-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  animation: slide-in .3s ease both;
}
.task-item .t-emoji {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; background: #f4f1ff; flex-shrink: 0;
}
.task-item .t-body { flex: 1; min-width: 0; }
.task-item .t-title { font-weight: 800; font-size: 16px; }
.task-item .t-meta { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.task-item.done { opacity: .75; }
.task-item.done .t-title { text-decoration: line-through; }

.tick {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px dashed #cfc8f2;
  background: #fbfaff;
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s ease, background .2s ease, border .2s ease;
}
.tick:hover { transform: scale(1.1); }
.tick.pending { border: 3px solid var(--sun); background: #fff6dd; animation: pulse 1.6s ease-in-out infinite; }
.tick.approved { border: 3px solid var(--mint); background: #d9f7ec; }

/* ── Rewards ── */
.reward-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.reward-card {
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
  text-align: center;
  animation: pop-in .35s ease both;
}
.reward-card .r-emoji { font-size: 40px; }
.reward-card .r-title { font-weight: 900; margin: 6px 0 2px; }
.reward-card .r-cost { font-size: 13px; color: var(--ink-soft); font-weight: 800; margin-bottom: 10px; }
.progress {
  height: 12px; border-radius: 999px; background: #eeeafd;
  overflow: hidden; margin: 8px 0 12px;
}
.progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--sun), #ff9f43);
  border-radius: 999px;
  transition: width .7s cubic-bezier(.2,.8,.3,1);
}
.progress.full > div { background: linear-gradient(90deg, var(--mint), #00e0a8); }

/* ── Calendar ── */
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.cal-day {
  background: var(--card);
  border-radius: 14px;
  padding: 10px 6px;
  min-height: 96px;
  box-shadow: var(--shadow-soft);
  font-size: 12px;
}
.cal-day.today { outline: 3px solid var(--brand); }
.cal-day .d-name { font-weight: 900; color: var(--ink-soft); text-align: center; font-size: 11px; }
.cal-day .d-num { font-weight: 900; text-align: center; font-size: 16px; margin-bottom: 4px; }
.cal-event {
  border-radius: 8px; padding: 3px 5px; margin-top: 3px;
  font-weight: 800; font-size: 10.5px;
  background: #f1eeff; color: var(--brand-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Parent dashboard ── */
.tabs {
  display: flex; gap: 6px; margin: 16px 0;
  background: #ffffffa8; border-radius: 16px; padding: 6px;
  box-shadow: var(--shadow-soft);
  overflow-x: auto;
}
.tab {
  border: none; background: transparent;
  padding: 10px 16px; border-radius: 12px;
  font-weight: 800; font-size: 14px; color: var(--ink-soft);
  cursor: pointer; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.tab.active { background: var(--brand); color: #fff; }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 2px solid #f2effc;
}
.list-row:last-child { border-bottom: none; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat {
  background: var(--card); border-radius: 18px; padding: 14px;
  box-shadow: var(--shadow-soft); text-align: center;
}
.stat .v { font-size: 26px; font-weight: 900; }
.stat .l { font-size: 12px; font-weight: 800; color: var(--ink-soft); }

/* ── PIN pad ── */
.pin-wrap { max-width: 340px; margin: 40px auto; text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 26px; }
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: #ddd8f5; transition: background .15s ease, transform .15s ease;
}
.pin-dot.filled { background: var(--brand); transform: scale(1.15); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pin-key {
  border: none; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow-soft);
  font-size: 24px; font-weight: 900; color: var(--ink);
  padding: 18px 0; cursor: pointer;
  transition: transform .1s ease;
}
.pin-key:active { transform: scale(.93); }
.pin-wrap.shake { animation: shake .4s ease; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(45, 42, 69, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
  animation: fade-in .2s ease;
}
.modal {
  background: var(--card); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 440px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: pop-in .3s cubic-bezier(.2,.9,.3,1.2);
}

/* ── Toast ── */
#toast-root { position: fixed; bottom: 20px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 999px;
  font-weight: 800; font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in .3s cubic-bezier(.2,.9,.3,1.3), fade-out .4s ease 2.6s both;
}

/* ── Confetti ── */
#confetti-root { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 80; }
.confetti {
  position: absolute; top: -20px;
  width: 12px; height: 12px;
  border-radius: 3px;
  animation: confetti-fall linear both;
}

/* ── Emoji picker ── */
.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.emoji-opt {
  border: 2px solid transparent; background: #f4f1ff;
  border-radius: 12px; font-size: 22px; padding: 6px 9px; cursor: pointer;
  transition: transform .1s ease;
}
.emoji-opt:hover { transform: scale(1.15); }
.emoji-opt.sel { border-color: var(--brand); background: #e6e1ff; }

.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-btn {
  border: 2px solid #e4e0f5; background: #fbfaff;
  border-radius: 10px; padding: 6px 10px;
  font-weight: 800; font-size: 13px; cursor: pointer; color: var(--ink-soft);
}
.day-btn.sel { background: var(--brand); border-color: var(--brand); color: #fff; }

.banner {
  border-radius: 16px; padding: 12px 16px; font-weight: 800; font-size: 14px;
  background: #fff3d1; color: #8a6100; margin-bottom: 16px;
  animation: pop-in .3s ease;
}

/* ── Animations ── */
@keyframes pop-in { from { opacity: 0; transform: scale(.92) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes twinkle { 0%,100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.2) rotate(12deg); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,197,49,.5); } 50% { box-shadow: 0 0 0 8px rgba(255,197,49,0); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes confetti-fall {
  from { transform: translateY(-5vh) rotate(0deg); opacity: 1; }
  to { transform: translateY(105vh) rotate(720deg); opacity: .7; }
}

@media (max-width: 640px) {
  .cal-week { grid-template-columns: repeat(7, minmax(44px, 1fr)); gap: 5px; }
  .cal-day { min-height: 80px; }
  .hero h2 { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
