@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Quicksand:wght@500;600;700&display=swap');

:root {
  --pink: #ff6fa5;
  --pink-dark: #f0508e;
  --pink-light: #ffe3ee;
  --pink-bg: #fff5f8;
  --yellow: #ffcb3d;
  --yellow-dark: #f5a623;
  --green: #3ecf8e;
  --red: #ff5c7a;
  --blue: #4fb8ff;
  --text: #4a3b45;
  --text-soft: #8a7a84;
  --card-bg: #ffffff;
  --border: #ffe0ea;
  --shadow: 0 6px 18px rgba(255, 111, 165, 0.12);
  --radius: 20px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Quicksand', 'Baloo 2', sans-serif;
  background: var(--pink-bg);
  color: var(--text);
}

h1, h2, h3, .brand-name {
  font-family: 'Baloo 2', 'Quicksand', sans-serif;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

img.avatar {
  object-fit: cover;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #fff 0%, #fff9fb 100%);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}

.brand .logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffb3cd, var(--pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--pink-dark);
  margin: 0;
}

.brand-tag {
  font-size: 12px;
  color: var(--text-soft);
  margin: 2px 0 0;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  transition: background .15s, color .15s;
}

.nav a .icon { font-size: 18px; width: 22px; text-align: center; }

.nav a:hover { background: var(--pink-light); }

.nav a.active {
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  color: #fff;
  box-shadow: 0 6px 14px rgba(240, 80, 142, 0.35);
}

.sidebar-footer {
  margin-top: auto;
  background: var(--pink-light);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  position: relative;
}

.sidebar-footer .mascot {
  font-size: 40px;
}

.sidebar-footer h4 {
  margin: 6px 0 4px;
  font-size: 14px;
  color: var(--pink-dark);
}

.sidebar-footer p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.4;
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  min-width: 0;
  padding: 26px 30px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 26px;
  margin: 0;
  color: var(--text);
}

.topbar .date-line {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  font-size: 14px;
  margin-top: 6px;
}

.topbar .date-line strong { color: var(--pink-dark); }

.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  box-shadow: var(--shadow);
}

.profile-chip .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pink-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  overflow: hidden;
}

.profile-chip .name { font-weight: 700; font-size: 14px; }
.profile-chip .sub { font-size: 12px; color: var(--text-soft); }

/* ---------- Layout grid ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 22px;
  align-items: start;
}

.sidebar-top { display: contents; }
.mobile-nav-checkbox { display: none; }
.mobile-nav-btn { display: none; }

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }

  .sidebar {
    width: 100%;
    flex-direction: column;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 40;
    gap: 0;
  }

  .sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
  }

  .brand { padding: 0; }
  .brand .logo { width: 38px; height: 38px; font-size: 18px; border-radius: 12px; }
  .brand-name { font-size: 16px; }
  .brand-tag { display: none; }

  .mobile-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--pink-light);
    color: var(--pink-dark);
    font-size: 20px;
    flex-shrink: 0;
    cursor: pointer;
  }

  .nav {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 4px 12px 12px;
    border-top: 1px solid var(--pink-light);
  }

  .nav a { border-radius: 12px; padding: 12px 14px; }

  .mobile-nav-checkbox:checked ~ .nav { display: flex; }

  .sidebar-footer { display: none; }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-head .title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
}

.card-head .sub {
  font-size: 13px;
  color: var(--text-soft);
  margin: 2px 0 0 32px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-weight: 700;
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-pink { background: var(--pink-light); color: var(--pink-dark); }
.btn-pink:hover { background: #ffd2e5; }
.btn-solid { background: linear-gradient(135deg, var(--pink), var(--pink-dark)); color: #fff; }
.btn-solid:hover { filter: brightness(1.05); }
.btn-green { background: #e4faf0; color: #1f9d63; }
.btn-green:hover { background: #cff5e4; }
.btn-outline { background: #fff; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--pink); }
.btn-danger { background: #ffe6ea; color: #d63455; }
.btn-danger:hover { background: #ffd3da; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Task table ---------- */
.task-table {
  width: 100%;
  border-collapse: collapse;
}

.task-table thead th {
  text-align: left;
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--text-soft);
  padding: 10px 12px;
  border-bottom: 2px solid var(--pink-light);
}

.task-table tbody td {
  padding: 12px;
  border-bottom: 1px solid #fbeef3;
  vertical-align: middle;
}

.task-table tbody tr:last-child td { border-bottom: none; }

.task-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.task-name {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.task-name .emoji { font-size: 22px; }

.status-btns { display: flex; gap: 8px; }

.status-btn {
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1.5px solid transparent;
  background: #f6f2f4;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-btn.done.active { background: #e4faf0; color: #1f9d63; border-color: #b7ecd3; }
.status-btn.miss.active { background: #ffe6ea; color: #d63455; border-color: #ffc4cf; }
.status-btn:not(.active):hover { background: #efe9eb; }

.star-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  color: var(--yellow-dark);
}

.table-legend {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--pink-light);
  border-radius: 12px;
  font-size: 13px;
  color: var(--pink-dark);
  text-align: center;
}

.tip-card {
  margin-top: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.tip-card .emoji { font-size: 26px; }

/* ---------- Right column ---------- */
.stars-card {
  background: linear-gradient(160deg, #fffdf3, #fff8e0);
  border-color: #ffedb0;
}

.stars-card .title { color: var(--yellow-dark); }

.stars-big {
  font-size: 46px;
  font-weight: 800;
  color: var(--yellow-dark);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stars-big .of { font-size: 20px; color: var(--text-soft); font-weight: 700; }
.stars-big .star-icon { font-size: 38px; }

.progressbar {
  height: 12px;
  border-radius: 999px;
  background: #ffe9b3;
  overflow: hidden;
  margin: 14px 0 6px;
}

.progressbar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--yellow-dark));
  border-radius: 999px;
  transition: width .4s ease;
}

.goal-card { text-align: center; }
.goal-box { font-size: 70px; margin: 6px 0; }
.goal-amount { font-size: 30px; font-weight: 800; color: var(--pink-dark); margin: 4px 0 0; }
.goal-name { font-size: 16px; font-weight: 700; color: var(--text-soft); margin-bottom: 10px; }

.message-card { background: #eef7ff; border-color: #cfe9ff; }
.message-card .title { color: #2277c9; }
.message-card p { font-size: 14px; line-height: 1.6; margin: 0; }

/* ---------- Generic page bits ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-soft);
}
.empty-state .emoji { font-size: 44px; display: block; margin-bottom: 10px; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pill.green { background: #e4faf0; color: #1f9d63; }
.pill.red { background: #ffe6ea; color: #d63455; }
.pill.gray { background: #f2eef0; color: var(--text-soft); }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label { font-size: 13px; font-weight: 700; color: var(--text-soft); }
.field input[type=text], .field input[type=number], .field select, .field textarea {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--pink);
}

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 160px; }

.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.icon-picker button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-picker button.active {
  border-color: var(--pink);
  background: var(--pink-light);
}

.list-editor { display: flex; flex-direction: column; gap: 10px; }
.list-editor .item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
}
.list-editor .item .emoji { font-size: 20px; }
.list-editor .item input { flex: 1; border: none; background: transparent; font-weight: 700; font-size: 14.5px; }
.list-editor .item input:focus { outline: none; }
.list-editor .drag-handle { color: #ccb9c2; cursor: grab; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: #f6f2f4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.icon-btn:hover { background: #efe1e7; }
.icon-btn.danger { color: #d63455; }
.icon-btn.danger:hover { background: #ffd3da; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 59, 69, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 22px;
  padding: 30px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal .emoji-big { font-size: 64px; }
.modal h2 { margin: 10px 0 6px; color: var(--pink-dark); }
.modal p { color: var(--text-soft); font-size: 14.5px; line-height: 1.6; margin-bottom: 20px; }
.modal .actions { display: flex; gap: 10px; justify-content: center; }
.hidden { display: none !important; }

/* history */
.history-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.day-block { border: 1.5px solid var(--border); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; }
.day-block .day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.day-block .day-head .date { font-weight: 800; }
.day-tasks { display: flex; flex-wrap: wrap; gap: 8px; }
.day-tasks .chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 5px 10px; font-size: 12.5px; font-weight: 700;
  background: #f6f2f4; color: var(--text-soft);
}
.day-tasks .chip.done { background: #e4faf0; color: #1f9d63; }
.day-tasks .chip.miss { background: #ffe6ea; color: #d63455; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-box { background: #fff; border: 1.5px solid var(--border); border-radius: 16px; padding: 16px; text-align: center; }
.stat-box .num { font-size: 26px; font-weight: 800; color: var(--pink-dark); }
.stat-box .label { font-size: 12.5px; color: var(--text-soft); margin-top: 4px; }
canvas { max-width: 100%; }

/* rewards */
.reward-tier {
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}
.reward-tier .box-emoji { font-size: 42px; }
.reward-tier .info { flex: 1; }
.reward-tier .info h3 { margin: 0 0 4px; font-size: 16px; }
.reward-tier .info p { margin: 0; font-size: 13px; color: var(--text-soft); }
.reward-tier.unlocked { background: #fffaf0; border-color: #ffedb0; }

.claim-history .entry {
  display: flex; justify-content: space-between; padding: 10px 0;
  border-bottom: 1px solid #fbeef3; font-size: 14px;
}
.claim-history .entry:last-child { border-bottom: none; }

.toggle {
  position: relative; width: 44px; height: 24px; border-radius: 999px;
  background: #e6dee1; flex-shrink: 0; border: none;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle.on { background: var(--pink); }
.toggle.on::after { transform: translateX(20px); }

.notif-item {
  display: flex; gap: 12px; padding: 14px; border-radius: 14px;
  background: #fdf9fa; margin-bottom: 10px; align-items: flex-start;
}
.notif-item .emoji { font-size: 22px; }
.notif-item .time { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.notif-item.unread { background: var(--pink-light); }

@media (max-width: 640px) {
  .main { padding: 18px 14px 50px; }
  .task-table thead { display: none; }
  .task-table, .task-table tbody, .task-table tr, .task-table td { display: block; width: 100%; }
  .task-table tbody tr { border: 1.5px solid var(--border); border-radius: 14px; margin-bottom: 10px; padding: 10px; }
  .task-table tbody td { border-bottom: none; padding: 6px 4px; }
}