:root {
  --bg:        #f3ebe1;
  --bg-soft:   #efe5d8;
  --card:      #fbf6ef;
  --ink:       #43342a;
  --ink-soft:  #7c6a5b;
  --line:      #e3d5c5;
  --coffee:    #6f4e37;
  --coffee-dk: #543a29;
  --terra:     #c0795a;
  --terra-dk:  #a8623f;
  --done:      #7f9b6e;
  --done-dk:   #5e7a4e;
  --miss:      #d8c2ad;
  --shadow:    0 10px 30px rgba(83, 58, 41, 0.12);
  --shadow-sm: 0 4px 14px rgba(83, 58, 41, 0.10);
  --radius:    18px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #f7efe4 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}

.wrap { width: min(1040px, 92vw); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
  padding: 38px 0 8px;
  text-align: center;
}
.brand {
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  margin: 0;
  color: var(--coffee-dk);
  letter-spacing: -0.5px;
}
.tagline {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-weight: 600;
}

.tabs {
  display: inline-flex;
  gap: 6px;
  margin-top: 22px;
  background: var(--bg-soft);
  padding: 6px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.98rem;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.tab:hover { color: var(--coffee); }
.tab.is-active {
  background: var(--coffee);
  color: #fbf6ef;
  box-shadow: var(--shadow-sm);
}

/* ---------- views ---------- */
.view { display: none; padding: 30px 0 10px; }
.view.is-active { display: block; animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.month-intro { text-align: center; margin-bottom: 24px; }
.month-intro h2 {
  font-family: "Fraunces", serif;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  color: var(--coffee-dk);
  margin: 0 0 6px;
}
.month-intro p { margin: 0 auto; max-width: 540px; color: var(--ink-soft); }

.banner {
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px;
  margin-bottom: 14px;
}
.banner.error { color: var(--terra-dk); }
.banner.hidden { display: none; }

/* ---------- calendars ---------- */
.calendars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 720px) {
  .calendars { grid-template-columns: 1fr; }
}

.cal-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 16px;
  border: 1px solid var(--line);
}
.cal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.who { display: flex; align-items: center; gap: 9px; }
.who h3 { font-family: "Fraunces", serif; margin: 0; font-size: 1.3rem; color: var(--coffee-dk); }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.dot-nio { background: var(--terra); }
.dot-paulina { background: var(--coffee); }

.streak {
  margin-left: auto;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--terra-dk);
  background: #f4e7dd;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.lock-btn {
  border: 0;
  background: var(--bg-soft);
  color: var(--coffee);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.lock-btn:hover { background: #e7d8c8; }
.lock-btn.unlocked { background: var(--done); color: #fff; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.dow {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 2px;
}
.day {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  background: #f1e7da;
  color: var(--ink-soft);
  border: 1.5px solid transparent;
  user-select: none;
  position: relative;
}
.day.empty { background: transparent; }
.day.editable { cursor: pointer; }
.day.editable:hover { border-color: var(--terra); }
.day.future { opacity: 0.45; }
.day.today { box-shadow: 0 0 0 2px var(--terra); }
.day .mark { font-size: 0.85rem; line-height: 1; margin-top: 1px; }

.day.done {
  background: var(--done);
  color: #fff;
}
.day.miss {
  background: var(--miss);
  color: #8a7763;
}

.cal-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 600;
  flex-wrap: wrap;
}
.legend { width: 12px; height: 12px; border-radius: 4px; display: inline-block; vertical-align: -1px; margin-right: 4px; }
.legend.done { background: var(--done); }
.legend.miss { background: var(--miss); }
.done-count { margin-left: auto; font-weight: 800; color: var(--coffee); }

/* ---------- result cards (past months) ---------- */
.result-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 760px) { .result-cards { grid-template-columns: 1fr; } }

.result-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px;
  text-align: center;
  border: 1px solid var(--line);
  border-top: 5px solid var(--line);
}
.result-card.pass { border-top-color: var(--done); }
.result-card.fail { border-top-color: var(--terra); }
.result-emoji { font-size: 2.6rem; }
.result-card h3 {
  font-family: "Fraunces", serif;
  margin: 8px 0 4px;
  font-size: 1.5rem;
  color: var(--coffee-dk);
}
.result-card .challenge { color: var(--ink-soft); margin: 0 0 16px; min-height: 2.6em; }
.verdict {
  font-weight: 800;
  font-size: 0.9rem;
  padding: 9px 12px;
  border-radius: 12px;
}
.verdict-pass { background: #e8efe1; color: var(--done-dk); }
.verdict-fail { background: #f6e6dd; color: var(--terra-dk); }

.record-line {
  text-align: center;
  margin-top: 28px;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* ---------- footer ---------- */
.site-footer {
  text-align: center;
  color: var(--ink-soft);
  padding: 36px 0 26px;
  font-size: 0.9rem;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(67, 52, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  width: min(360px, 100%);
  animation: fade 0.2s ease;
}
.modal h3 { font-family: "Fraunces", serif; margin: 0 0 4px; color: var(--coffee-dk); }
.modal-sub { margin: 0 0 16px; color: var(--ink-soft); font-size: 0.9rem; }
.modal input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
}
.modal input:focus { outline: none; border-color: var(--terra); }
.modal-err { color: var(--terra-dk); font-weight: 700; font-size: 0.85rem; margin: 8px 0 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.btn {
  border: 0;
  background: var(--coffee);
  color: #fbf6ef;
  font-family: inherit;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--coffee-dk); }
.btn.ghost { background: var(--bg-soft); color: var(--coffee); }
.btn.ghost:hover { background: #e7d8c8; }

/* ---------- mobile refinements ---------- */
@media (max-width: 480px) {
  .brand { font-size: 1.7rem; }
  .tagline { font-size: 0.9rem; }

  .tabs { flex-wrap: wrap; justify-content: center; }
  .tab { padding: 8px 14px; font-size: 0.88rem; }

  .month-intro h2 { font-size: 1.3rem; }
  .month-intro p { font-size: 0.9rem; }

  .cal-card { padding: 14px 12px 12px; }
  .cal-head { flex-wrap: wrap; gap: 8px; }
  .who h3 { font-size: 1.1rem; }
  .streak { font-size: 0.75rem; padding: 3px 9px; }
  .lock-btn { font-size: 0.75rem; padding: 6px 10px; }

  .cal-grid { gap: 4px; }
  .day { font-size: 0.8rem; border-radius: 8px; }
  .day .mark { font-size: 0.7rem; }

  .cal-foot { gap: 10px; font-size: 0.72rem; }
  .legend { width: 10px; height: 10px; }

  .result-card { padding: 20px 16px; }
  .result-emoji { font-size: 2.2rem; }
  .result-card h3 { font-size: 1.3rem; }
  .result-card .challenge { font-size: 0.9rem; min-height: auto; }
  .verdict { font-size: 0.82rem; padding: 8px 10px; }

  .modal { padding: 20px; }
  .modal h3 { font-size: 1.1rem; }
  .modal input { padding: 10px 12px; font-size: 0.95rem; }
}
