/* ============================================================
   Samskaras — warm Indic palette, mobile-first
   saffron #FF9933 · turmeric #FFD700 · lotus #FF6B9D
   peacock #00897B · cream #FFF8E7
   ============================================================ */
:root {
  --saffron: #FF9933;
  --saffron-deep: #E67E00;
  --turmeric: #FFD700;
  --lotus: #FF6B9D;
  --peacock: #00897B;
  --peacock-soft: #B2DFDB;
  --cream: #FFF8E7;
  --card: #FFFFFF;
  --ink: #4E342E;
  --ink-soft: #8D6E63;
  --done: #E8F5E9;
  --done-edge: #66BB6A;
  --radius: 20px;
  --shadow: 0 4px 14px rgba(230, 126, 0, 0.14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  background: var(--cream);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(255, 215, 0, 0.10) 0 140px, transparent 140px),
    radial-gradient(circle at 88% 20%, rgba(255, 107, 157, 0.08) 0 160px, transparent 160px),
    radial-gradient(circle at 50% 90%, rgba(0, 137, 123, 0.06) 0 200px, transparent 200px);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- signature: marigold toran garland along the top edge --- */
.toran {
  height: 14px;
  background:
    radial-gradient(circle at 6px -3px, var(--turmeric) 0 7px, var(--saffron) 7px 10px, transparent 10px);
  background-size: 22px 14px;
  background-repeat: repeat-x;
  filter: drop-shadow(0 2px 2px rgba(230, 126, 0, 0.25));
}

/* --- layout --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
}
.brand {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--saffron-deep);
  text-decoration: none;
}
.topnav { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.topnav a { color: var(--peacock); font-weight: 600; text-decoration: none; }
.whoami { font-weight: 700; }

.page {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0.5rem 1rem 2.5rem;
}
.footer {
  text-align: center;
  padding: 1rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.page-title { font-size: 1.5rem; font-weight: 800; margin: 0.6rem 0; }
.section-title { font-size: 1.15rem; font-weight: 700; margin: 1.4rem 0 0.6rem; }
.muted { color: var(--ink-soft); font-size: 0.9rem; }
.empty { color: var(--ink-soft); padding: 0.8rem 0.4rem; }

/* --- cards & buttons --- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.1s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--saffron), var(--saffron-deep));
  color: #fff;
  box-shadow: 0 3px 8px rgba(230, 126, 0, 0.35);
}
.btn-ghost {
  background: transparent;
  color: var(--peacock);
  border: 2px solid var(--peacock-soft);
}
.btn-big { font-size: 1.2rem; padding: 0.8rem 1.6rem; }

.icon-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.15rem;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--cream); }

/* --- flashes --- */
.flash {
  border-radius: 14px;
  padding: 0.6rem 1rem;
  margin: 0.6rem 0;
  font-weight: 600;
}
.flash-ok { background: var(--done); color: #2E7D32; }
.flash-error { background: #FDECEA; color: #C0392B; }

/* --- forms --- */
.stack { display: flex; flex-direction: column; gap: 0.7rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem; }
.inline-form.wrap { flex-wrap: wrap; }
.inline-form.grow { flex: 1; }
.field-label { font-weight: 600; color: var(--ink-soft); }
.text-input {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.8rem;
  border: 2px solid #F0E1C6;
  border-radius: 12px;
  background: #FFFDF7;
  min-width: 0;
  flex: 1;
}
.text-input.tiny { flex: 0 0 5.5rem; }
.text-input:focus { outline: 3px solid var(--turmeric); border-color: var(--saffron); }
.pin-input {
  font-family: inherit;
  font-size: 2rem;
  text-align: center;
  letter-spacing: 0.6rem;
  padding: 0.6rem;
  border: 3px solid var(--saffron);
  border-radius: 16px;
  width: 100%;
}
.pin-input:focus { outline: 4px solid var(--turmeric); }

/* --- login --- */
.login-hero { text-align: center; margin: 1.2rem 0 1rem; }
.login-lamp { font-size: 3.5rem; animation: flicker 3s ease-in-out infinite; }
.login-hero h1 { font-size: 2.2rem; font-weight: 800; color: var(--saffron-deep); }
.tagline { color: var(--ink-soft); font-weight: 600; }

.family-grid, .avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.9rem;
}
.family-card, .avatar-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 0.8rem;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  border: 3px solid transparent;
}
.family-card:hover, .avatar-card:hover,
.family-card:focus-visible, .avatar-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--turmeric);
}
.family-icon, .avatar-face { font-size: 2.6rem; }
.family-name, .avatar-name { font-weight: 700; font-size: 1.05rem; }
.avatar-role { font-size: 0.8rem; color: var(--ink-soft); }

.login-card { max-width: 380px; margin: 0 auto; text-align: center; }
.login-card.wide { max-width: 460px; text-align: left; }
.login-card.wide .btn-big { align-self: center; }
.sub-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.5rem; }
.settings-card { margin-top: 1rem; }
.settings-card .field-label { flex: 0 0 8.5rem; }
.grow { flex: 1; }
.login-avatar { font-size: 4rem; }
.login-card h2 { margin: 0.3rem 0 0.8rem; }
.back-link {
  display: inline-block;
  margin-top: 0.9rem;
  color: var(--peacock);
  font-weight: 600;
  text-decoration: none;
}
.admin-login { text-align: center; margin-top: 1.5rem; }

/* --- child dashboard --- */
.hello-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, #FFF3D6, #FFE4EC);
  border: 3px solid var(--turmeric);
}
.hello-avatar { font-size: 3.2rem; }
.hello-greet { font-weight: 600; color: var(--ink-soft); }
.hello-name { font-size: 1.8rem; font-weight: 800; color: var(--saffron-deep); }

.progress-wrap { margin: 1rem 0; }
.progress-bar {
  height: 22px;
  background: #F3E8D2;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar.small { height: 12px; margin: 0.5rem 0; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--turmeric), var(--saffron));
  border-radius: 999px;
  transition: width 0.5s ease;
}
.progress-label { text-align: center; font-weight: 700; margin-top: 0.3rem; }

.task-list { display: flex; flex-direction: column; gap: 0.7rem; }
.task-form { display: block; }
.task-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 3px solid #F3E4C8;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s ease, background 0.2s ease, border-color 0.2s ease;
}
.task-card:active { transform: scale(0.98); }
.task-icon { font-size: 1.8rem; }
.task-title { flex: 1; }
.task-check { font-size: 1.3rem; min-width: 1.6rem; }
.task-done {
  background: var(--done);
  border-color: var(--done-edge);
  color: #2E7D32;
}

.stars-bar {
  position: sticky;
  bottom: 0.8rem;
  margin-top: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 3px solid var(--turmeric);
}
.stars-count { font-size: 1.15rem; font-weight: 800; }
.stars-count.big { font-size: 1.4rem; text-align: center; margin-bottom: 0.6rem; }

/* --- rewards --- */
.rewards-dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(78, 52, 46, 0.3);
  padding: 1.2rem;
  width: min(92vw, 420px);
  font-family: inherit;
  color: var(--ink);
}
.rewards-dialog::backdrop { background: rgba(78, 52, 46, 0.45); }
.reward-list { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.6rem 0; }
.reward-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: #FFFDF7;
  border: 2px solid #F3E4C8;
  border-radius: 14px;
  padding: 0.6rem 0.9rem;
  font-weight: 700;
}
.reward-icon { font-size: 1.6rem; }
.reward-title { flex: 1; }
.reward-cost { color: var(--ink-soft); white-space: nowrap; }
.reward-ready { border-color: var(--turmeric); background: #FFF7DB; }
.reward-ready .reward-cost { color: var(--saffron-deep); }

/* --- parent panel --- */
.child-grid { display: flex; flex-direction: column; gap: 1rem; }
.child-head { display: flex; align-items: center; gap: 0.8rem; }
.child-avatar { font-size: 2.4rem; }
.mini-task-list { list-style: none; margin: 0.6rem 0; }
.mini-task {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px dashed #F0E1C6;
  font-weight: 600;
}
.mini-task:last-child { border-bottom: none; }
.mini-done span:first-child { color: #2E7D32; }
.mini-actions { display: flex; align-items: center; gap: 0.2rem; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.history-table th {
  text-align: left;
  color: var(--ink-soft);
  font-weight: 700;
  padding: 0.4rem 0.6rem;
  border-bottom: 2px solid var(--turmeric);
}
.history-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid #F5EBD8; }

/* --- admin --- */
.admin-list { list-style: none; }
.admin-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
}

/* --- animations --- */
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  50% { transform: scale(1.08) rotate(2deg); }
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
.task-pop { animation: pop 0.45s ease; }

.burst-star {
  position: fixed;
  font-size: 1.4rem;
  pointer-events: none;
  z-index: 999;
  animation: burst 0.9s ease-out forwards;
}
@keyframes burst {
  0% { transform: translate(0, 0) scale(0.6) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.4) rotate(220deg); opacity: 0; }
}

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

/* --- wider screens --- */
@media (min-width: 720px) {
  .page { max-width: 860px; }
  .child-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
