:root {
  color-scheme: light;
  --ink: #24315f;
  --muted: #626a8f;
  --line: #d7dafa;
  --panel: #ffffff;
  --paper: #fff6c7;
  --mint: #c4f7d7;
  --mint-strong: #137a52;
  --coral: #ffd0de;
  --coral-strong: #b82e64;
  --blue: #cde9ff;
  --blue-strong: #276fc2;
  --gold: #ffe66d;
  --gold-strong: #815600;
  --grape: #dec9ff;
  --grape-strong: #6b3fbe;
  --orange: #ffd29b;
  --orange-strong: #a55300;
  --shadow: 0 18px 40px rgba(66, 75, 135, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.26) 0 14px, transparent 14px 28px),
    linear-gradient(135deg, #ffef7f 0%, #bdeeff 38%, #ffd1e0 72%, #c9f7dc 100%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.login-active .app-shell {
  display: none;
}

body:not(.login-active) .login-shell {
  display: none;
}

body.child-mode .sidebar,
body.child-mode .profile-strip {
  display: none;
}

body.child-mode .layout {
  grid-template-columns: minmax(0, 1fr);
}

body.child-mode .workspace {
  min-height: 520px;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.login-shell {
  width: min(440px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.login-panel {
  width: 100%;
  padding: 28px;
  border: 2px solid rgba(36, 49, 95, 0.11);
  border-radius: 8px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 18px, transparent 18px 36px),
    #ffdc5e;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 22px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 800;
}

.login-form input {
  width: 100%;
  min-height: 44px;
  border: 2px solid rgba(36, 49, 95, 0.15);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

.login-form button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 14px;
  background: #5b4bd6;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(36, 49, 95, 0.16);
}

.form-error {
  min-height: 1.2em;
  color: #8c2f23;
  font-weight: 800;
}

.session-pill {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-weight: 800;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar,
.summary-band,
.layout,
.profile-strip,
.review-panel,
.task-card,
.reward-card,
.compact-row,
.request-row,
.history-row,
.empty-state {
  border: 2px solid rgba(36, 49, 95, 0.11);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 96px;
  padding: 20px 24px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 18px, transparent 18px 36px),
    #ffdc5e;
  border-radius: 8px 8px 0 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1;
  letter-spacing: 0;
  color: #34245f;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.78);
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.eyebrow,
.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions,
.section-heading,
.tabs,
.inline-form,
.editor-form,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost-button,
.icon-button,
.tab,
.inline-form button,
.editor-form button,
.task-card button,
.reward-card button,
.request-actions button,
.danger-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  background: #5b4bd6;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(36, 49, 95, 0.16);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  box-shadow: 0 2px 0 rgba(36, 49, 95, 0.16);
  transform: translateY(1px);
}

.ghost-button {
  background: #ffffff;
  color: var(--ink);
}

.ghost-button.danger {
  color: #8c2f23;
}

.danger-button {
  background: var(--coral);
  color: var(--coral-strong);
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 1.2rem;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border-top: 0;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.summary-band > div {
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.78);
}

.summary-band > div:nth-child(1) {
  background: var(--gold);
}

.summary-band > div:nth-child(2) {
  background: var(--mint);
}

.summary-band > div:nth-child(3) {
  background: var(--grape);
}

.summary-band strong {
  display: block;
  margin-top: 4px;
  font-size: 1.7rem;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  margin-top: 18px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.68);
}

.sidebar {
  min-height: 640px;
  padding: 18px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.38) 0 16px, transparent 16px 32px),
    rgba(255, 209, 224, 0.78);
  border-right: 1px solid var(--line);
}

.workspace {
  min-width: 0;
  padding: 18px;
  background: rgba(255, 253, 240, 0.74);
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 12px;
}

.kid-list,
.task-list,
.reward-list,
.compact-list,
.request-list,
.history-list {
  display: grid;
  gap: 10px;
}

.kid-list {
  margin-bottom: 14px;
}

.task-list,
.reward-list {
  padding: 8px;
  overflow: visible;
}

.review-panel {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 8px;
}

.request-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.request-actions {
  display: flex;
  gap: 8px;
}

.kid-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  transition: transform 180ms ease, background 180ms ease;
}

.kid-row.active {
  background: #ffffff;
  outline: 3px solid var(--blue);
  transform: rotate(-0.35deg);
}

.kid-button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.kid-button strong {
  overflow-wrap: anywhere;
}

.kid-button span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.remove-kid-button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--coral);
  color: var(--coral-strong);
  font-weight: 900;
  box-shadow: none;
}

.mini-avatar,
.avatar {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--gold);
  color: var(--gold-strong);
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(129, 86, 0, 0.12);
}

.mini-avatar {
  width: 42px;
  height: 42px;
}

.avatar {
  width: 64px;
  height: 64px;
  font-size: 1.6rem;
}

.inline-form,
.editor-form {
  align-items: stretch;
}

input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.tabs {
  margin-bottom: 18px;
}

.tab {
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
}

.tab.active {
  background: #5b4bd6;
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.profile-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 230, 109, 0.5), rgba(205, 233, 255, 0.78)),
    #ffffff;
}

.profile-strip h2 {
  margin-top: 2px;
  font-size: 1.8rem;
  overflow-wrap: anywhere;
}

.balance {
  min-width: 112px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--gold-strong);
  text-align: center;
}

.balance span {
  display: block;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.balance strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.two-column > section {
  min-width: 0;
  overflow: visible;
}

.task-card,
.reward-card,
.compact-row,
.history-row,
.empty-state {
  border-radius: 8px;
  padding: 14px;
}

.task-card,
.reward-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border-color: rgba(36, 49, 95, 0.22);
  background-clip: padding-box;
  position: relative;
  overflow: visible;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.task-card:hover,
.reward-card:hover {
  transform: translateY(-2px);
}

.task-card {
  background:
    linear-gradient(90deg, rgba(205, 233, 255, 0.46), rgba(255, 255, 255, 0.86)),
    #ffffff;
}

.task-card.done {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.24) 0 10px, transparent 10px 20px),
    var(--mint);
  border-color: rgba(19, 122, 82, 0.28);
}

.reward-card {
  background:
    linear-gradient(90deg, rgba(255, 210, 155, 0.55), rgba(255, 255, 255, 0.88)),
    #ffffff;
}

.card-title {
  display: block;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.card-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.task-card button {
  background: #10a86f;
}

.task-card.done button {
  background: #ffffff;
  color: var(--mint-strong);
}

.reward-card button {
  background: #ff8a2a;
}

.reward-card button:disabled {
  cursor: not-allowed;
  background: #d9dde3;
  color: #7b8490;
  box-shadow: none;
  transform: none;
}

.pill {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--blue);
  color: var(--blue-strong);
  font-size: 0.78rem;
  font-weight: 900;
}

.editor-form {
  grid-template-columns: minmax(0, 1fr) 86px auto;
  margin-bottom: 12px;
}

.compact-row,
.history-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: none;
}

.compact-row button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--coral);
  color: var(--coral-strong);
  font-weight: 900;
}

.history-row span,
.empty-state span {
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  display: grid;
  gap: 4px;
  text-align: center;
  box-shadow: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(36, 49, 95, 0.34);
  z-index: 10;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(420px, 100%);
  border: 2px solid rgba(36, 49, 95, 0.11);
  border-radius: 8px;
  padding: 20px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 230, 109, 0.18) 0 14px, transparent 14px 28px),
    rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.modal-panel h2 {
  margin-top: 4px;
  font-size: 1.35rem;
}

.modal-copy {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.celebration-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 20;
}

.burst-piece {
  position: absolute;
  width: var(--size, 18px);
  height: var(--size, 18px);
  border-radius: 4px;
  background: var(--gold);
  transform: translate(-50%, -50%);
  animation: burst 2100ms cubic-bezier(0.14, 0.86, 0.22, 1) forwards;
}

.burst-piece:nth-child(3n) {
  border-radius: 999px;
  background: var(--blue);
}

.burst-piece:nth-child(3n + 1) {
  background: var(--coral);
  clip-path: polygon(50% 0, 63% 34%, 100% 38%, 72% 61%, 80% 100%, 50% 78%, 20% 100%, 28% 61%, 0 38%, 37% 34%);
}

.burst-piece.reward {
  background: var(--orange);
}

.burst-piece.reward:nth-child(3n) {
  background: var(--grape);
}

.chore-pop {
  animation: chore-pop 940ms cubic-bezier(0.18, 0.9, 0.2, 1.18) both;
}

.reward-pop {
  animation: reward-pop 1050ms cubic-bezier(0.15, 0.9, 0.2, 1.18) both;
}

.balance-pop {
  animation: balance-pop 980ms cubic-bezier(0.18, 0.9, 0.2, 1.18) both;
}

.action-boom {
  animation: action-boom 860ms cubic-bezier(0.14, 0.9, 0.24, 1.18) both;
}

@keyframes chore-pop {
  0% {
    transform: scale(1);
  }

  24% {
    transform: scale(1.16) rotate(-2.2deg);
  }

  52% {
    transform: scale(0.97) rotate(1.2deg);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes reward-pop {
  0% {
    transform: scale(1);
  }

  24% {
    transform: scale(1.2) rotate(2.4deg);
  }

  50% {
    transform: scale(0.95) rotate(-1.4deg);
  }

  74% {
    transform: scale(1.06) rotate(0.7deg);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes balance-pop {
  0% {
    transform: scale(1);
  }

  28% {
    transform: scale(1.14) rotate(-0.8deg);
  }

  58% {
    transform: scale(0.98) rotate(0.35deg);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes action-boom {
  0% {
    transform: scale(1);
  }

  22% {
    transform: scale(1.28) rotate(-4deg);
  }

  52% {
    transform: scale(0.9) rotate(2deg);
  }

  78% {
    transform: scale(1.08) rotate(-1deg);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes burst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
  }

  16% {
    opacity: 1;
    transform: translate(calc(-50% + var(--pop-tx)), calc(-50% + var(--pop-ty))) scale(1.55) rotate(110deg);
  }

  58% {
    opacity: 0.9;
    transform: translate(calc(-50% + var(--mid-tx)), calc(-50% + var(--mid-ty))) scale(1.05) rotate(310deg);
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.78) rotate(560deg);
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .topbar,
  .profile-strip {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .layout,
  .two-column {
    grid-template-columns: 1fr;
  }

  .summary-band {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-band > div {
    padding: 12px 10px;
    text-align: center;
  }

  .summary-band strong {
    margin-top: 2px;
    font-size: 1.35rem;
  }

  .sidebar {
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .kid-list {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }

  .balance {
    width: 100%;
  }

  .editor-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar {
    min-height: 0;
    padding: 14px;
  }

  h1 {
    font-size: 2rem;
  }

  .summary-band > div {
    min-width: 0;
    padding: 9px 6px;
  }

  .metric-label {
    font-size: 0.62rem;
    line-height: 1.1;
  }

  .summary-band strong {
    font-size: 1.12rem;
  }

  .topbar-actions,
  .tabs,
  .inline-form {
    width: 100%;
  }

  .topbar-actions > *,
  .tabs > *,
  .inline-form > * {
    flex: 1;
  }

  .task-card,
  .reward-card,
  .compact-row,
  .history-row {
    grid-template-columns: 1fr;
  }

  .task-card button,
  .reward-card button {
    width: 100%;
  }

  .modal-actions {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .celebration-layer {
    display: none;
  }
}
