:root {
  --ink: #2b2a4c;
  --paper: #fff6e9;
  --card: #ffffff;
  --coral: #ff7a6b;
  --teal: #2ec4b6;
  --sun: #ffd166;
  --grape: #8e7cf0;
  --mint: #c9f2e3;
  --blush: #ffe1dc;
  --muted: #7a789a;
  --m0: var(--coral);
  --m1: var(--teal);
  --radius: 22px;
  --shadow: 4px 4px 0 var(--ink);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(43, 42, 76, .09) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  min-height: 100dvh;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom));
}

h1 { font-size: 30px; margin: 0; letter-spacing: -.5px; }
h2 { font-size: 20px; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 15px; }
.center { text-align: center; }

/* --- cards & buttons --- */

.card {
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 0 0 18px;
}
.card.sun { background: var(--sun); }
.card.mint { background: var(--mint); }
.card.blush { background: var(--blush); }

button, input, textarea { font: inherit; color: inherit; }
/* no double-tap zoom, so a tap is a click straight away */
button, a, input, label { touch-action: manipulation; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 8px 18px;
  font-weight: 800;
  background: var(--coral);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: box-shadow .08s, filter .08s;
}
/* Pressed look without moving the button: a button that slides out from
   under the finger on press can lose the click when tapped near its edge. */
.btn:active { box-shadow: 0 0 0 var(--ink); filter: brightness(.9); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.teal { background: var(--teal); }
.btn.sun { background: var(--sun); }
.btn.plain { background: var(--card); }
.btn.small { min-height: 38px; padding: 4px 14px; font-size: 15px; }
.btn.wide { width: 100%; }

.link {
  background: none;
  border: 0;
  padding: 6px 2px;
  color: var(--muted);
  font-size: 15px;
  text-decoration: underline;
  cursor: pointer;
}

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

label, .caption { display: block; font-weight: 700; font-size: 15px; }

input[type=text], input[type=date], input[type=time], textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  padding: 10px 14px;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  outline: none;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus { box-shadow: 0 0 0 4px var(--sun); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  padding: 7px 13px;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.chip.on { background: var(--sun); box-shadow: 2px 2px 0 var(--ink); }

/* --- people --- */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  font-size: 24px;
  background: var(--sun);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
}
.avatar.m0 { background: var(--m0); }
.avatar.m1 { background: var(--m1); }
.avatar.small { width: 30px; height: 30px; font-size: 16px; border-width: 2px; }
.avatar.none { background: var(--card); border-style: dashed; color: var(--muted); font-weight: 800; }

/* --- header & mascot --- */

.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.top .date { display: inline-block; color: var(--muted); font-weight: 700; }
.top .date::first-letter, .day-head b::first-letter { text-transform: uppercase; }

.mascot-row { display: flex; align-items: center; gap: 6px; margin-bottom: 18px; }
.mascot { width: 104px; flex: none; animation: bob 3.2s ease-in-out infinite; }
.mascot.big { width: 150px; display: block; margin: 0 auto; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }

.bubble {
  position: relative;
  padding: 12px 14px;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  font-weight: 700;
}
.bubble::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%;
  width: 14px;
  height: 14px;
  background: var(--card);
  border-left: 2.5px solid var(--ink);
  border-bottom: 2.5px solid var(--ink);
  transform: translateY(-50%) rotate(45deg);
}

/* --- mood --- */

.moods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mood {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s;
}
.mood span { font-size: 30px; line-height: 1.15; }
.mood.on { background: var(--sun); box-shadow: 3px 3px 0 var(--ink); transform: translate(-2px, -2px) rotate(-3deg); }

.feeling { display: flex; gap: 12px; align-items: flex-start; }
.feeling + .feeling { margin-top: 14px; padding-top: 14px; border-top: 2px dashed rgba(43, 42, 76, .2); }
.feeling .big { font-size: 34px; line-height: 1; }
.feeling .what { font-weight: 800; }
.feeling .note { font-style: italic; }
.tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--mint);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.history { display: grid; grid-template-columns: 34px repeat(7, 1fr); gap: 6px 2px; align-items: center; text-align: center; }
.history .dayname { font-size: 12px; font-weight: 700; color: var(--muted); }
.history .cell { font-size: 20px; }
.history .cell.empty { color: rgba(43, 42, 76, .25); }

/* --- week --- */

.weeknav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.weeknav .round { width: 46px; padding: 0; font-size: 20px; }

.day { padding: 12px 14px; }
.day.today { background: var(--sun); }
.day.past { opacity: .6; }
.day-head { display: flex; align-items: center; justify-content: space-between; }
.day-head b { display: inline-block; font-size: 18px; }
.add {
  width: 36px;
  height: 36px;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.event {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  text-align: left;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-left-width: 10px;
  border-radius: 14px;
  cursor: pointer;
}
.event.m0 { border-left-color: var(--m0); }
.event.m1 { border-left-color: var(--m1); }
.event.none { border-style: dashed; border-left-style: solid; border-left-color: var(--muted); }
.event .time { font-weight: 800; font-size: 14px; min-width: 44px; }
.event .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event .swap { font-size: 13px; color: var(--muted); }

/* --- jar --- */

.jar { display: block; width: 190px; margin: 0 auto 6px; }
.jar.shake { animation: shake .5s; }
@keyframes shake {
  20% { transform: rotate(-7deg); }
  40% { transform: rotate(6deg); }
  60% { transform: rotate(-4deg); }
  80% { transform: rotate(3deg); }
}

.slip {
  padding: 12px 14px;
  margin-top: 10px;
  background: var(--sun);
  border: 2.5px solid var(--ink);
  border-radius: 6px 18px 8px 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.slip:nth-child(3n+1) { background: var(--blush); transform: rotate(-.8deg); }
.slip:nth-child(3n+2) { background: var(--mint); transform: rotate(.7deg); }
.slip .from { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); font-weight: 700; }
.slip.pop { animation: pop .45s backwards; }
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(.8) rotate(-6deg); } }

/* --- us --- */

.code {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
}
.kid { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-weight: 700; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.emoji-pick button {
  width: 42px;
  height: 42px;
  font-size: 22px;
  background: var(--card);
  border: 2.5px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}
.emoji-pick button.on { border-color: var(--ink); background: var(--sun); }

/* --- tabs, sheet, toast, confetti --- */

nav#tabs {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  width: min(488px, calc(100% - 24px));
  padding: 6px;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
nav#tabs[hidden] { display: none; }
nav#tabs button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0 4px;
  background: none;
  border: 0;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
nav#tabs button span { font-size: 22px; line-height: 1.2; }
nav#tabs button.on { background: var(--sun); }

dialog#sheet {
  width: min(520px, 100%);
  max-width: 100%;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  color: var(--ink);
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  overflow-y: auto;
}
dialog#sheet[open] { animation: rise .22s ease-out; }
dialog#sheet::backdrop { background: rgba(43, 42, 76, .45); }
@keyframes rise { from { transform: translateY(40%); opacity: 0; } }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
  z-index: 20;
}

.confetti {
  position: fixed;
  top: -16px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 30;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  .mascot, .jar.shake, .slip.pop, dialog#sheet[open] { animation: none; }
  .confetti { display: none; }
}
