@import url("fonts.css");

:root {
  --pink-bg: #fff5f8;
  --pink-bg-2: #ffe9f1;
  --pink-100: #ffd6e5;
  --pink-200: #ffc2d9;
  --pink-300: #ffa8c8;
  --pink-400: #ff8fb8;
  --pink-500: #f472a0;
  --rose-deep: #e35d8c;
  --lavender: #e8d9ff;
  --mint: #d9f7ea;
  --text-main: #5a3b47;
  --text-muted: #a9808f;
  --white-card: #ffffff;
  --border-soft: #ffe0ec;
  --shadow-soft: 0 6px 18px rgba(244, 114, 160, 0.14);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --pink-bg: #2a1720;
    --pink-bg-2: #33192a;
    --pink-100: #4a2436;
    --pink-200: #5a2c40;
    --white-card: #3a1e2c;
    --text-main: #ffe3ee;
    --text-muted: #d59db4;
    --border-soft: #55283c;
    --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, var(--pink-bg-2) 0%, var(--pink-bg) 220px);
  color: var(--text-main);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, .brand-name, .form-title, .section-title {
  font-family: "Quicksand", "Nunito", sans-serif;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(84px + var(--safe-bottom));
  position: relative;
}

.topbar {
  padding: calc(14px + var(--safe-top)) 16px 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, var(--pink-bg-2) 60%, transparent);
  backdrop-filter: blur(6px);
}

.brand { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; }
.brand-emoji { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 19px; color: var(--rose-deep); letter-spacing: 0.3px; }

.settings-btn {
  position: absolute;
  right: 16px;
  border: none;
  background: var(--pink-100);
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}

.view { padding: 8px 16px 24px; }

/* ---------- Page header ---------- */
.page-header { padding: 6px 4px 14px; }
.page-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--rose-deep);
}

.home-header { padding: 10px 4px 4px; }
.home-greeting { display: flex; align-items: center; gap: 12px; }
.home-emoji {
  font-size: 34px;
  background: var(--pink-100);
  border-radius: 50%;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft);
}
.home-greeting h1 { margin: 0; font-size: 26px; color: var(--rose-deep); }
.home-date { margin: 2px 0 0; color: var(--text-muted); font-size: 14px; font-weight: 600; }

.highlight-banner {
  margin: 14px 4px 18px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--pink-200), var(--lavender));
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  color: var(--rose-deep);
  box-shadow: var(--shadow-soft);
}
.highlight-banner strong { color: #7a2a4f; }

/* ---------- Cards ---------- */
.card {
  background: var(--white-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-soft);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 16px;
  color: var(--rose-deep);
  margin-bottom: 10px;
}
.section-title-right { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.muted-note { color: var(--text-muted); font-size: 14px; margin: 4px 0; }
.muted-note.small { font-size: 12.5px; }

/* ---------- Settings / backup ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.stat-chip {
  background: var(--pink-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
}
.stat-chip strong { display: block; font-size: 18px; color: var(--rose-deep); }
.stat-chip span { font-size: 11px; color: var(--text-muted); font-weight: 600; }

.btn-block { display: block; width: 100%; text-align: center; }

.btn-secondary {
  display: block;
  border: 1.5px solid var(--pink-300);
  background: #fff;
  color: var(--rose-deep);
  font-weight: 700;
  font-size: 14.5px;
  padding: 10px 18px;
  border-radius: 999px;
  font-family: inherit;
  cursor: pointer;
}
.btn-secondary:active { transform: scale(0.98); }
@media (prefers-color-scheme: dark) {
  .btn-secondary { background: var(--pink-bg); }
}

.settings-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 16px 0;
}

/* ---------- Checklist rows ---------- */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}
.check-row:last-of-type { border-bottom: none; }
.check-row input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }

.check-box {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--pink-300);
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.check-row input:checked + .check-box {
  background: var(--pink-400);
  border-color: var(--pink-400);
}
.check-row input:checked + .check-box::after {
  content: "✓";
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.check-text { flex: 1; display: flex; flex-direction: column; }
.check-label { font-weight: 700; font-size: 15px; }
.check-row.done .check-label { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--pink-300); }
.check-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }

.badge-new {
  flex: none;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--lavender);
  align-self: center;
}

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 18px 8px; color: var(--text-muted); }
.empty-emoji { font-size: 30px; margin-bottom: 6px; }
.empty-state p { margin: 0; font-size: 14px; }

/* ---------- Subtabs ---------- */
.subtabs {
  display: flex;
  gap: 8px;
  margin: 0 2px 16px;
  background: var(--pink-100);
  padding: 4px;
  border-radius: 999px;
}
.subtab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 6px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--rose-deep);
  font-family: inherit;
}
.subtab-btn.active { background: #fff; box-shadow: var(--shadow-soft); }

/* ---------- Item / step cards ---------- */
.item-card {
  background: var(--pink-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.item-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-name { font-weight: 700; font-size: 15px; }
.item-brand { font-size: 12.5px; color: var(--text-muted); background: var(--pink-100); padding: 2px 8px; border-radius: 999px; }
.item-notes { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.item-actions { display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end; }

.pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--rose-deep);
  background: var(--mint);
  padding: 2px 9px;
  border-radius: 999px;
}

.step-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--pink-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.step-order {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--pink-300);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.step-main { flex: 1; min-width: 0; }
.step-label { font-weight: 700; font-size: 14.5px; }
.step-sub { font-size: 12px; color: var(--text-muted); }
.step-actions { display: flex; gap: 4px; flex: none; flex-wrap: wrap; justify-content: flex-end; max-width: 100px; }

.icon-btn {
  border: none;
  background: var(--pink-100);
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  color: var(--rose-deep);
}
.icon-btn:disabled { opacity: 0.35; }

/* ---------- Forms ---------- */
.mini-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-title { font-weight: 700; font-size: 14px; color: var(--rose-deep); margin-bottom: 2px; }
.field-label { font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin-top: 2px; }

.mini-form input,
.mini-form select,
.mini-form textarea {
  width: 100%;
  border: 1.5px solid var(--border-soft);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text-main);
}
@media (prefers-color-scheme: dark) {
  .mini-form input, .mini-form select, .mini-form textarea { background: var(--pink-bg); }
}
.mini-form textarea { resize: vertical; min-height: 44px; }
.mini-form input:focus, .mini-form select:focus, .mini-form textarea:focus {
  outline: none;
  border-color: var(--pink-400);
}

.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  font-family: inherit;
}
.btn-primary:active { transform: scale(0.98); }

.btn-text {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13.5px;
  font-family: inherit;
}

/* ---------- Day picker chips ---------- */
.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-chip {
  border: 1.5px solid var(--pink-200);
  background: #fff;
  color: var(--rose-deep);
  font-weight: 700;
  font-size: 12.5px;
  padding: 7px 0;
  width: 42px;
  border-radius: 999px;
  font-family: inherit;
}
.day-chip.selected {
  background: var(--pink-400);
  border-color: var(--pink-400);
  color: #fff;
}
@media (prefers-color-scheme: dark) {
  .day-chip { background: var(--pink-bg); }
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  background: var(--white-card);
  border-top: 1px solid var(--border-soft);
  padding: 8px 6px calc(8px + var(--safe-bottom));
  box-shadow: 0 -4px 16px rgba(244, 114, 160, 0.12);
  z-index: 10;
}
.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--text-muted);
  font-family: inherit;
}
.tab-icon { font-size: 20px; }
.tab-label { font-size: 10.5px; font-weight: 700; }
.tab-btn.active { color: var(--rose-deep); }
.tab-btn.active .tab-icon { transform: scale(1.12); }

/* ---------- Calendar ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-month-label { font-weight: 700; color: var(--rose-deep); font-size: 16px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid-head { margin-bottom: 4px; }
.cal-head { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-muted); }

.cal-cell {
  aspect-ratio: 1;
  border: none;
  background: var(--pink-bg);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: inherit;
  color: var(--text-main);
}
.cal-cell.empty { background: transparent; }
.cal-cell.is-today { border: 1.5px solid var(--pink-400); }
.cal-cell.selected { background: var(--pink-400); color: #fff; }
.cal-daynum { font-size: 12.5px; font-weight: 700; }
.cal-dots { display: flex; gap: 3px; height: 6px; }
.dot { width: 5px; height: 5px; border-radius: 50%; }
.dot-scheduled { background: var(--lavender); border: 1px solid var(--pink-300); }
.dot-logged { background: var(--pink-500); }
.cal-cell.selected .dot-scheduled { background: rgba(255,255,255,0.6); border-color: #fff; }
.cal-cell.selected .dot-logged { background: #fff; }

.cal-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--text-muted); align-items: center; }
.cal-legend .dot { display: inline-block; margin-right: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  background: var(--rose-deep);
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
