:root {
  --pink-1: #F1A6C9;
  --pink-2: #EC7EC0;
  --pink-3: #F0559F;
  --pink-4: #EC008C;

  --green-1: #A3D9A0;
  --green-2: #8FCB8B;
  --green-3: #7BBE7D;
  --green-4: #66AE6D;
  --green-5: #4C9F5C;

  --ivory: #FFFBF7;
  --cream: #FFF3F8;
  --charcoal: #33362f;
  --red-overdue: #E53935;

  --shadow: 0 4px 14px rgba(140, 60, 100, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(180deg, var(--cream) 0%, var(--ivory) 40%);
  color: var(--charcoal);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

h1, h2 { font-family: 'Playfair Display', serif; }

.bg-flourish {
  position: fixed;
  width: 220px;
  height: 220px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
.bg-flourish.top-left { top: -60px; left: -60px; }
.bg-flourish.bottom-right { bottom: -60px; right: -60px; transform: rotate(180deg); }
.bg-flourish svg { width: 100%; height: 100%; }

.app-header, .tab-nav, main {
  position: relative;
  z-index: 1;
}

.app-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 16px 12px;
  text-align: center;
}

.app-title {
  margin: 0;
  font-size: 1.9rem;
  color: var(--pink-4);
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

.countdown-card {
  background: linear-gradient(135deg, var(--pink-1), var(--pink-2));
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 14px 28px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 200px;
  transition: transform 0.15s ease;
}
.countdown-card:hover { transform: translateY(-2px); }
#countdown-number {
  font-size: 2.4rem;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  line-height: 1;
}
#countdown-label {
  font-size: 0.85rem;
  opacity: 0.95;
  margin-top: 4px;
}

.tab-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px 0;
}
.tab-btn {
  flex: 1;
  max-width: 220px;
  padding: 12px 16px;
  border: none;
  border-radius: 999px;
  background: rgba(255,255,255,0.6);
  color: var(--charcoal);
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.tab-btn.active {
  background: var(--pink-4);
  color: white;
  box-shadow: var(--shadow);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  background: white;
  padding: 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.add-form input {
  flex: 1 1 140px;
  padding: 10px 12px;
  border: 1.5px solid var(--pink-1);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  min-width: 0;
}
.add-form input:focus { outline: 2px solid var(--pink-3); }
.add-form button {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: var(--green-5);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.add-form button:hover { background: var(--green-4); }

.empty-state {
  text-align: center;
  color: #8a8a80;
  font-style: italic;
  margin-top: 24px;
}

/* Task list */
.task-list, .budget-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  background: white;
  border-left: 6px solid var(--green-1);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.15s ease;
}

.task-item.status-far { border-left-color: var(--green-2); background: var(--ivory); }
.task-item.status-soon { border-left-color: var(--pink-2); background: linear-gradient(90deg, #fff, var(--cream)); }
.task-item.status-soon-close { border-left-color: var(--pink-4); background: linear-gradient(90deg, #fff, #ffe3f0); }
.task-item.status-overdue {
  border-left-color: var(--red-overdue);
  background: #fff0ef;
  animation: pulse-flash 1.6s ease-in-out infinite;
}
.task-item.status-completed {
  border-left-color: var(--green-5);
  background: #f1fbf2;
  opacity: 0.85;
}

@keyframes pulse-flash {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 4px 20px rgba(229, 57, 53, 0.45); }
}

.task-check {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--green-5);
}

.task-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-title-input, .task-date-input {
  border: none;
  background: transparent;
  font-family: inherit;
  padding: 2px 4px;
  border-radius: 6px;
}
.task-title-input {
  font-size: 1rem;
  font-weight: 500;
}
.task-title-input:focus, .task-date-input:focus {
  outline: 1.5px solid var(--pink-2);
  background: white;
}
.task-item.status-completed .task-title-input {
  text-decoration: line-through;
  color: #6a6a60;
}

.task-date-input { font-size: 0.8rem; color: #666; width: fit-content; }

.task-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  color: white;
  white-space: nowrap;
}
.task-item.status-overdue .task-badge { background: var(--red-overdue); }
.task-item.status-soon-close .task-badge { background: var(--pink-4); }
.task-item.status-soon .task-badge { background: var(--pink-2); }
.task-item.status-far .task-badge { background: var(--green-3); }
.task-item.status-completed .task-badge { background: var(--green-5); }

.task-delete {
  background: none;
  border: none;
  color: #b0473f;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}
.task-delete:hover { background: #ffe1de; }

/* Budget */
.budget-summary {
  background: linear-gradient(135deg, var(--green-1), var(--green-2));
  border-radius: var(--radius);
  padding: 16px 18px;
  color: #1e3320;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.budget-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.budget-total-row input {
  width: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  text-align: right;
}
.remaining-display {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid rgba(30, 51, 32, 0.25);
  padding-top: 10px;
}
.remaining-label { font-size: 0.9rem; opacity: 0.85; }
.remaining-amount {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 700;
}
.remaining-amount.over-budget { color: var(--red-overdue); }

.budget-item {
  background: white;
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 6px solid var(--pink-1);
}
.budget-item.purchased {
  border-left-color: var(--green-5);
  background: #f1fbf2;
}
.budget-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.budget-name-input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 500;
  padding: 2px 4px;
  border-radius: 6px;
}
.budget-costs {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.8rem;
  color: #666;
  flex-wrap: wrap;
}
.budget-costs input {
  width: 90px;
  border: none;
  background: transparent;
  font-family: inherit;
  padding: 2px 4px;
  border-radius: 6px;
}
.budget-name-input:focus, .budget-costs input:focus {
  outline: 1.5px solid var(--pink-2);
  background: white;
}
.purchase-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.purchase-btn.to-purchase { background: var(--pink-4); color: white; }
.purchase-btn.purchased-badge { background: var(--green-5); color: white; }

.budget-delete {
  background: none;
  border: none;
  color: #b0473f;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
}
.budget-delete:hover { background: #ffe1de; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(50, 30, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 16px;
}
.modal-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}
.modal-card h2 { margin-top: 0; color: var(--pink-4); font-size: 1.3rem; }
.modal-card input {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1.5px solid var(--pink-1);
  font-family: inherit;
  margin-bottom: 16px;
  font-size: 1rem;
}
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.btn-primary, .btn-secondary {
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--pink-4); color: white; }
.btn-secondary { background: #eee; color: #444; }

/* Desktop */
@media (min-width: 720px) {
  main { padding: 28px 16px 100px; }
  .app-title { font-size: 2.4rem; }
  .tab-btn { font-size: 1.05rem; }
}
