:root {
  --bg: #f4efe6;
  --card: #fffdf8;
  --raised: #f7f1e6;
  --ink: #2d2a26;
  --soft: #7a7268;
  --line: #e7ddcd;
  --accent: #c8643a;
  --sun: #f2b33d;
  --sky: #3f8fd2;
  --leaf: #3f9a5c;
  --leaf-soft: #e3f2e6;
  --now: #fff3d6;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Nunito', system-ui, -apple-system, sans-serif;
  --r: 22px;
  --shadow: 0 1px 0 rgba(60, 40, 20, .04), 0 8px 24px -14px rgba(60, 40, 20, .25);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 500 17px/1.35 var(--sans);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  gap: 14px;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
h2 { font: 650 22px/1.1 var(--serif); margin: 0 0 12px; letter-spacing: -.01em; }
.muted { color: var(--soft); }
.kid-name { color: var(--accent); }

/* Header */
.top { display: flex; align-items: center; gap: 18px; }
.clock { flex: 1; min-width: 0; }
.time { font: 650 64px/0.95 var(--serif); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.time small { font-size: 26px; margin-left: 6px; color: var(--soft); letter-spacing: 0; }
.date { font-weight: 800; font-size: 20px; color: var(--soft); margin-top: 4px; }
.birthday {
  font: 650 24px/1.1 var(--serif); color: var(--accent);
  background: var(--card); border: 2px dashed var(--sun); border-radius: 999px; padding: 10px 20px;
  animation: bob 2.4s ease-in-out infinite;
}
.weather-pill {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--r); padding: 10px 18px 10px 12px; box-shadow: var(--shadow);
  text-align: left;
}
.wx-icon { font-size: 46px; line-height: 1; }
.wx-now { display: flex; flex-direction: column; }
.wx-temp { font: 650 34px/1 var(--serif); }
.wx-label { font-size: 14px; color: var(--soft); font-weight: 700; }
.wx-hilo { font-weight: 800; font-size: 17px; display: flex; flex-direction: column; gap: 2px; padding-left: 12px; border-left: 1px solid var(--line); }
.wx-hilo .hi { color: var(--accent); }
.wx-hilo .lo { color: var(--sky); }

/* Grid */
.grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.05fr 0.95fr 1.1fr; gap: 14px; }
.col-family { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-height: 0; display: flex; flex-direction: column; }

/* Photos */
.photo-frame {
  position: relative; aspect-ratio: 4 / 3; max-height: 42%; border-radius: var(--r); overflow: hidden;
  background: linear-gradient(135deg, #e9d9c2, #d7e3e8); box-shadow: var(--shadow); flex-shrink: 0;
}
.photo-frame img, .saver-photos img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 1.6s ease;
}
.photo-frame img.on, .saver-photos img.on { opacity: 1; }
.photo-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: #6d6458; font-weight: 700; }

/* Calendar */
.cal { flex: 1; }
.agenda { overflow-y: auto; margin: 0 -6px; padding: 0 6px; -webkit-overflow-scrolling: touch; }
.day-group + .day-group { margin-top: 14px; }
.day-label { font-weight: 900; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--soft); margin-bottom: 6px; }
.day-group.today .day-label { color: var(--accent); }
.ev { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 8px 10px; border-radius: 12px; align-items: baseline; }
.ev + .ev { margin-top: 2px; }
.ev .when { font-weight: 800; font-size: 14px; color: var(--soft); font-variant-numeric: tabular-nums; }
.ev .what { font-weight: 800; font-size: 17px; line-height: 1.25; }
.ev .where { display: block; font-weight: 600; font-size: 13px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev { background: var(--raised); border-left: 4px solid var(--feed, var(--accent)); }
.ev.allday .when { color: var(--accent); }
.ev.past { opacity: .45; }
.ev.special { background: #fff1d1; }
.day-empty { font-size: 15px; color: var(--soft); padding: 4px 2px; }

/* Evan's day */
.schedule { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin: 0 -6px; padding: 2px 6px 6px; }
.blk { display: grid; grid-template-columns: 50px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 16px; transition: background .4s; text-align: left; width: 100%; }
.blk .emo { font-size: 32px; text-align: center; }
.blk .t { font-weight: 800; font-size: 13px; color: var(--soft); }
.blk .n { font-weight: 900; font-size: 19px; line-height: 1.15; }
.blk .tag { font-weight: 900; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 4px 9px; border-radius: 999px; }
.blk.past { opacity: .4; }
.blk.past .n { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(0, 0, 0, .25); }
.blk.now { background: var(--now); box-shadow: inset 0 0 0 3px var(--sun); padding: 14px 12px; }
.blk.now .emo { font-size: 46px; animation: bob 2.4s ease-in-out infinite; }
.blk.now .n { font-size: 24px; }
.blk.now .tag { background: var(--sun); color: #4a3200; }
.blk.next .tag { background: var(--raised); color: var(--soft); }
.blk .bar { grid-column: 2 / 4; height: 8px; border-radius: 99px; background: rgba(0, 0, 0, .07); overflow: hidden; }
.blk .bar i { display: block; height: 100%; background: var(--sun); border-radius: 99px; }

/* Evan's jobs */
.jobs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.jobs-head h2 { margin: 0; }
.stars { display: flex; align-items: center; gap: 6px; background: #fff3d1; border-radius: 999px; padding: 6px 14px 6px 10px; font: 900 22px/1 var(--sans); color: #6a4a00; }
.stars .star-glyph { font-size: 24px; }
.stars.pop { animation: pop .6s cubic-bezier(.3, 1.6, .5, 1); }
.chores { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin: 0 -6px; padding: 2px 6px 6px; }
.chore {
  display: grid; grid-template-columns: 48px 1fr 46px; align-items: center; gap: 10px;
  background: var(--raised); border-radius: 18px; padding: 12px 14px; text-align: left; width: 100%;
  border: 3px solid transparent; transition: transform .15s, background .3s, border-color .3s;
}
.chore:active { transform: scale(.97); }
.chore .emo { font-size: 40px; text-align: center; }
.chore .name { font-weight: 900; font-size: 18px; line-height: 1.15; }
.chore .hint { display: block; font-weight: 700; font-size: 13px; color: var(--soft); }
.chore .box { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #cfc3b0; display: grid; place-items: center; font-size: 28px; color: #fff; transition: all .3s; }
.chore.done { background: var(--leaf-soft); border-color: #bfe3c8; }
.chore.done .box { background: var(--leaf); border-color: var(--leaf); }
.chore.done .name { color: #2f6b41; }
.chore.just .box { animation: pop .6s cubic-bezier(.3, 1.6, .5, 1); }
.chore.weekly .hint::before { content: 'This week · '; }
.jobs-foot { display: flex; gap: 10px; margin-top: 12px; }
.rewards-btn { flex: 1; background: var(--accent); color: #fff; font-weight: 900; font-size: 19px; border-radius: 16px; padding: 14px; }
.parent-btn { width: 52px; border-radius: 16px; background: var(--raised); color: var(--soft); font-size: 22px; }
.all-done-note { text-align: center; font-weight: 900; color: var(--leaf); padding: 6px; }

/* Sheets */
.sheet {
  border: 0; border-radius: 26px; padding: 22px 24px; width: min(720px, 92vw); max-height: 86vh;
  background: var(--card); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); margin: auto;
}
.sheet::backdrop { background: rgba(40, 30, 20, .45); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 28px; }
.close { width: 44px; height: 44px; border-radius: 50%; background: var(--raised); font-size: 18px; font-weight: 900; }
.wx-now-big { display: flex; align-items: center; gap: 18px; margin: 8px 0 18px; }
.wx-now-big .i { font-size: 72px; }
.wx-now-big .t { font: 650 60px/1 var(--serif); }
.wx-now-big .d { color: var(--soft); font-weight: 700; }
.hours { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 18px; }
.hour { flex: 0 0 64px; text-align: center; background: var(--raised); border-radius: 14px; padding: 10px 4px; }
.hour .h { font-size: 13px; font-weight: 800; color: var(--soft); }
.hour .i { font-size: 26px; margin: 4px 0; }
.hour .tp { font-weight: 900; }
.hour .pp { font-size: 12px; color: var(--sky); font-weight: 800; min-height: 15px; }
.days { display: flex; flex-direction: column; gap: 6px; }
.dayrow { display: grid; grid-template-columns: 70px 40px 1fr 60px 120px; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--raised); font-weight: 800; }
.dayrow .i { font-size: 26px; }
.dayrow .lbl { color: var(--soft); font-size: 14px; }
.dayrow .pp { color: var(--sky); font-size: 14px; }
.dayrow .range { display: flex; gap: 8px; justify-content: flex-end; }
.dayrow .hi { color: var(--accent); }
.dayrow .lo { color: var(--sky); }

.rewards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; overflow-y: auto; }
.reward { background: var(--raised); border-radius: 18px; padding: 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.reward .emo { font-size: 50px; }
.reward .rt { font-weight: 900; font-size: 18px; line-height: 1.2; }
.reward .cost { font-weight: 900; color: #6a4a00; }
.reward .meter { width: 100%; height: 12px; border-radius: 99px; background: rgba(0, 0, 0, .08); overflow: hidden; }
.reward .meter i { display: block; height: 100%; background: var(--sun); }
.reward .need { font-size: 14px; font-weight: 800; color: var(--soft); }
.reward.ready { background: #fff1cc; box-shadow: inset 0 0 0 3px var(--sun); }
.reward.ready .need { color: var(--leaf); }

.pin { width: min(380px, 92vw); text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 12px 0 20px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--soft); }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); }
.pin-dots.bad { animation: shake .4s; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pin-pad button { height: 68px; border-radius: 18px; background: var(--raised); font: 900 28px/1 var(--sans); }
.pin-pad button:active { background: var(--line); }

.psec { margin-top: 18px; }
.psec h3 { font: 900 13px/1 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--soft); margin: 0 0 10px; }
.prow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--raised); border-radius: 14px; margin-bottom: 6px; font-weight: 800; }
.prow .grow { flex: 1; }
.prow button, .pbtn { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 8px 14px; font-weight: 900; }
.prow button.go { background: var(--accent); border-color: var(--accent); color: #fff; }
.prow button:disabled { opacity: .35; }
.prow .sub { color: var(--soft); font-size: 14px; font-weight: 700; }
.hist { font-size: 14px; color: var(--soft); }
.hist div { display: flex; justify-content: space-between; padding: 4px 2px; border-bottom: 1px solid var(--line); }
.hist .plus { color: var(--leaf); font-weight: 900; }
.hist .minus { color: var(--accent); font-weight: 900; }
.switch { width: 54px; height: 32px; border-radius: 99px; background: #d8cfc1; position: relative; transition: background .2s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on { background: var(--leaf); }
.switch.on::after { left: 25px; }

/* Screensaver + night */
.saver { position: fixed; inset: 0; z-index: 40; background: #14110d; color: #fff; }
.saver-photos { position: absolute; inset: 0; }
.saver-photos img { object-fit: cover; animation: drift 24s ease-in-out infinite alternate; }
.saver-photos.empty { background: radial-gradient(circle at 30% 20%, #3b4e63, #14110d 70%); }
.saver-info { position: absolute; left: 40px; bottom: 34px; text-shadow: 0 2px 18px rgba(0, 0, 0, .6); }
.saver-time { font: 650 96px/0.9 var(--serif); letter-spacing: -.03em; }
.saver-date { font-weight: 800; font-size: 24px; opacity: .9; margin-top: 8px; }
.saver-wx { font-weight: 800; font-size: 22px; opacity: .9; margin-top: 4px; }
.saver.night .saver-photos { opacity: .25; }
.saver.night .saver-info { opacity: .55; }

/* Celebrations */
.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 62; }
.cheer { position: fixed; inset: 0; z-index: 61; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(255, 250, 240, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.cheer .big { font-size: 170px; line-height: 1; animation: zoomspin 1s cubic-bezier(.3, 1.5, .5, 1) both; }
.cheer .words { font: 650 64px/1 var(--serif); color: var(--accent); text-align: center; animation: rise .6s .25s both; text-shadow: 0 3px 0 #fff; }
.cheer .earned { font: 900 34px/1 var(--sans); color: #6a4a00; background: #fff3d1; border-radius: 999px; padding: 10px 24px; animation: rise .6s .45s both; }
.cheer.all .big { font-size: 200px; animation: zoomspin 1s cubic-bezier(.3, 1.5, .5, 1) both, dance 0.9s 1s ease-in-out infinite; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 14px; font-weight: 800; z-index: 70; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes zoomspin { from { transform: scale(0) rotate(-200deg); } to { transform: scale(1) rotate(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
@keyframes dance { 0%, 100% { transform: rotate(-10deg) scale(1); } 50% { transform: rotate(10deg) scale(1.08); } }
@keyframes drift { from { transform: scale(1.02); } to { transform: scale(1.12) translate(-1.5%, -1%); } }

/* Portrait iPad / narrow */
@media (max-width: 900px) {
  body { overflow-y: auto; }
  .time { font-size: 52px; }
  .grid { grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(420px, auto); }
  .col-family { grid-column: 1 / -1; flex-direction: row; }
  .photo-frame { flex: 1; max-height: none; }
  .cal { flex: 1.2; }
}
@media (max-width: 600px) {
  .top { flex-wrap: wrap; }
  .grid { grid-template-columns: 1fr; }
  .col-family { flex-direction: column; }
  .birthday { order: 3; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
