:root {
  --ink: #0b3d4a;
  --ink-soft: #2a5a66;
  --muted: #5f7d86;
  --paper: #e8f4f2;
  --paper-2: #f7fbfa;
  --teal: #1fa8a0;
  --teal-deep: #14857e;
  --coral: #f07a54;
  --coral-deep: #d96540;
  --sun: #f4c95f;
  --line: rgba(11, 61, 74, 0.12);
  --shadow: 0 14px 34px rgba(11, 61, 74, 0.12);
  --radius: 22px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --tabbar-h: 74px;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overscroll-behavior-y: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 70% at 10% -10%, rgba(244, 201, 95, 0.45), transparent 55%),
    radial-gradient(90% 60% at 100% 0%, rgba(31, 168, 160, 0.35), transparent 50%),
    radial-gradient(80% 50% at 50% 100%, rgba(240, 122, 84, 0.18), transparent 55%),
    linear-gradient(180deg, #d9efe9 0%, #e8f4f2 38%, #f4faf8 100%);
}

.app-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%230b3d4a' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-top)) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  animation: rise-in 0.45s ease both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-screen {
  width: min(480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(28px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
  display: grid;
  align-content: center;
  animation: rise-in 0.45s ease both;
}

/* Author `display` rules override the HTML hidden attribute unless forced */
.login-screen[hidden],
.app[hidden],
.modal-root[hidden],
.login-error[hidden] {
  display: none !important;
}

.login-card {
  padding: 24px 20px 22px;
  border-radius: calc(var(--radius) + 6px);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.login-brand {
  margin-bottom: 14px;
}

.login-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.login-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
  font-weight: 750;
  font-size: 0.92rem;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.45));
  box-shadow: var(--shadow);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.brand-kicker {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 20px rgba(11, 61, 74, 0.08);
}

.icon-btn:active {
  transform: scale(0.96);
}

.view {
  display: grid;
  gap: 16px;
}

.hero-panel {
  position: relative;
  overflow: hidden;
  padding: 22px 20px 20px;
  border-radius: calc(var(--radius) + 4px);
  color: #f7fffd;
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(244, 201, 95, 0.35), transparent 55%),
    linear-gradient(145deg, #0f4d5c 0%, #14857e 58%, #1fa8a0 100%);
  box-shadow: var(--shadow);
  animation: panel-pop 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes panel-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero-panel h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 650;
}

.hero-panel p {
  margin: 0;
  max-width: 28ch;
  color: rgba(247, 255, 253, 0.84);
  font-weight: 600;
  line-height: 1.35;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.section-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.section-head p,
.subtle {
  margin: 0;
  color: var(--muted);
  font-weight: 650;
  font-size: 0.92rem;
}

.kid-grid {
  display: grid;
  gap: 12px;
}

.kid-tile {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: var(--radius);
  text-align: left;
  color: inherit;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 24px rgba(11, 61, 74, 0.07);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: tile-in 0.4s ease both;
}

.kid-tile:nth-child(2) {
  animation-delay: 0.05s;
}
.kid-tile:nth-child(3) {
  animation-delay: 0.1s;
}
.kid-tile:nth-child(4) {
  animation-delay: 0.15s;
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.kid-tile:active {
  transform: scale(0.985);
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: white;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.kid-meta strong {
  display: block;
  font-size: 1.08rem;
  font-weight: 800;
}

.kid-meta span {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.money-chip {
  min-width: 76px;
  padding: 10px 12px;
  border-radius: 16px;
  text-align: right;
  background: rgba(31, 168, 160, 0.12);
  color: var(--teal-deep);
  font-weight: 800;
}

.money-chip small {
  display: block;
  font-size: 0.72rem;
  font-weight: 750;
  opacity: 0.75;
}

.balance-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  padding: 14px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 18px rgba(11, 61, 74, 0.06);
}

.stat .label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat .value {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}

.stat.available .value {
  color: var(--teal-deep);
}
.stat.savings .value {
  color: #b45309;
}
.stat.earned .value {
  color: var(--ink);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 16px;
  min-height: 48px;
  padding: 12px 16px;
  font-weight: 800;
  color: white;
  background: var(--teal);
  box-shadow: 0 10px 20px rgba(20, 133, 126, 0.25);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.coral {
  background: var(--coral);
  box-shadow: 0 10px 20px rgba(217, 101, 64, 0.28);
}

.btn.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: none;
  border: 1px solid var(--line);
}

.btn.sun {
  color: var(--ink);
  background: var(--sun);
  box-shadow: 0 10px 20px rgba(244, 201, 95, 0.35);
}

.btn.full {
  width: 100%;
}

.btn.danger {
  background: #dc2626;
  box-shadow: 0 10px 20px rgba(220, 38, 38, 0.25);
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 18px rgba(11, 61, 74, 0.06);
}

.list-item .title {
  margin: 0;
  font-weight: 800;
}

.list-item .meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.reward-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(244, 201, 95, 0.35);
  color: #8a5a00;
  font-weight: 800;
  font-size: 0.92rem;
}

.chore-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tiny-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(11, 61, 74, 0.08);
  color: var(--ink);
}

.tiny-btn.danger {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

.back-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font-weight: 800;
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-weight: 800;
  font-size: 0.92rem;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 168, 160, 0.18);
}

.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.color-swatch.selected {
  border-color: var(--ink);
  transform: scale(1.08);
}

.empty {
  padding: 28px 18px;
  border-radius: var(--radius);
  text-align: center;
  background: rgba(255, 255, 255, 0.65);
  border: 1px dashed rgba(11, 61, 74, 0.18);
}

.empty h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
}

.empty p {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.activity-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
}

.dot.cashout {
  background: var(--coral);
}
.dot.savings {
  background: var(--sun);
}
.dot.savings_withdraw {
  background: #60a5fa;
}

.amount-pos {
  color: var(--teal-deep);
  font-weight: 800;
}
.amount-neg {
  color: var(--coral-deep);
  font-weight: 800;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 10px 10px calc(10px + var(--safe-bottom));
  background: rgba(247, 251, 250, 0.88);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(11, 61, 74, 0.08);
  z-index: 20;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 800;
}

.tab-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}

.tab-icon svg {
  width: 22px;
  height: 22px;
}

.tab.active {
  color: var(--ink);
  background: rgba(31, 168, 160, 0.14);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  transform: translateX(-50%) translateY(16px);
  width: min(420px, calc(100% - 28px));
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: white;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
  justify-items: center;
}

.modal-root[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 30, 36, 0.45);
  animation: fade 0.2s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  position: relative;
  width: min(480px, 100%);
  max-height: min(88dvh, 720px);
  overflow: auto;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  border-radius: 28px 28px 0 0;
  background: #f7fbfa;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.18);
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheet-up {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.modal-body {
  display: grid;
  gap: 12px;
}

.quick-amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.quick-amounts button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  font-weight: 800;
  color: var(--ink);
}

.child-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.child-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
}

.pulse {
  animation: pulse 0.45s ease;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

@media (min-width: 720px) {
  .app {
    padding-top: 28px;
  }

  .modal-root {
    align-items: center;
  }

  .modal {
    border-radius: 24px;
    margin-bottom: 0;
    width: min(440px, calc(100% - 32px));
  }
}
