:root {
  --bg: #FFF8EA;
  --panel: #FFFFFF;
  --ink: #1B2430;
  --muted: #6B7280;
  --rule: #EEE6D6;
  --sky: #2D6E8E;
  --sun: #FFC93C;
  --leaf: #3F8F4E;
  --display: "Fredoka", "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #BFE6FA 0%, #DDF2F7 45%, #EEF8E6 100%) fixed;
  color: var(--ink);
  font-family: "IBM Plex Sans", -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.board {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 150px;
}

/* --- zoo background: fixed behind the content, never clickable --- */
.zoo-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.zoo { position: absolute; }
.zoo.sun      { top: 18px; right: 4vw; width: 96px; height: 96px; }
.zoo.cloud    { width: 130px; height: 65px; opacity: .9; }
.zoo.cloud.c1 { top: 90px; left: 12vw; }
.zoo.cloud.c2 { top: 40px; right: 16vw; width: 100px; height: 50px; }
.zoo.monkey   { top: 0; left: 2vw; width: 110px; height: 170px; }
.zoo.giraffe  { bottom: 38px; left: 1.5vw; width: 150px; height: 290px; }
.zoo.elephant { bottom: 26px; right: 2vw; width: 210px; height: 175px; }
.zoo.penguin  { bottom: 22px; left: calc(1.5vw + 118px); width: 60px; height: 84px; }
.hills {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 120px;
}
.zoo.cloud, .zoo.monkey { animation: drift 7s ease-in-out infinite alternate; }
.zoo.monkey { animation-name: swing; transform-origin: 50% 0; }
@keyframes drift { to { transform: translateX(24px); } }
@keyframes swing { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@media (prefers-reduced-motion: reduce) {
  .zoo { animation: none !important; }
}
/* when the window is narrower than the board plus the animals, keep them
   behind the content and quieter so text stays easy to read */
@media (max-width: 1360px) {
  .zoo.monkey, .zoo.giraffe, .zoo.elephant, .zoo.penguin { opacity: .35; }
}

/* --- brand header --- */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.brand-mascot {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 0 rgba(154, 90, 30, .25));
}
.brand-text { flex: 1; min-width: 0; }
.brand-kicker {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #9A5A1E;
}
.brand-title {
  margin: -2px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 44px;
  line-height: 1;
  letter-spacing: .01em;
}
.brand-title span {
  display: inline-block;
  text-shadow: 0 3px 0 rgba(27, 36, 48, .14);
}
.brand-title .l { color: #E0752D; transform: rotate(-6deg); }
.brand-title .e { color: #2FA37A; transform: translateY(-3px); }
.brand-title .o { color: #3A8BD1; transform: rotate(6deg); }
.brand-title .app { color: var(--ink); margin-left: 4px; }
.weather-now {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: rgba(255, 255, 255, .8);
  border-radius: 16px;
  padding: 8px 14px;
  box-shadow: 0 2px 0 rgba(27, 36, 48, .06);
}
.weather-now .temp {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
}
.weather-now .cond {
  color: var(--muted);
  font-size: 12px;
}
.brand-kicker, .brand-title { white-space: nowrap; }
@media (max-width: 640px) {
  .brand { gap: 10px; }
  .brand-mascot { width: 48px; height: 48px; }
  .brand-kicker { font-size: 11px; }
  .brand-title { font-size: 30px; }
  .weather-now { padding: 6px 10px; }
  .weather-now .temp { font-size: 20px; }
  .weather-now .cond { display: none; }
}

/* --- hero: who has Leo today --- */
.hero {
  border: 2px solid;
  border-radius: 18px;
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 3px 0 rgba(27, 36, 48, .06);
}
.hero-label {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px;
}
.hero-status {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 700;
  margin: 0;
}
.handoff-banner {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.handoff-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px;
}
.handoff-weather {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}
.handoff-note {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
}
.checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.check-row input { cursor: pointer; }
.checked-off {
  color: var(--muted);
  text-decoration: line-through;
}

/* --- overnight tally panel --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 16px 20px;
  margin-bottom: 8px;
  box-shadow: 0 3px 0 rgba(27, 36, 48, .06);
}
.tally-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.section-label {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  color: #9A5A1E;
  margin: 0 0 10px;
}
.tally-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
}
.swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}
.tally-name { flex: 1; min-width: 0; }
.tally-count {
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
}
.tally-pct {
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
  font-size: 11px;
  width: 42px;
  text-align: right;
}
.tally-note {
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0 0;
}
.csv-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--sky);
  text-decoration: none;
}
.csv-link:hover { text-decoration: underline; }
.flag-note {
  font-size: 12px;
  color: #A63A3A;
  margin: 8px 2px 20px;
}

@media (max-width: 640px) {
  .tally-panel { grid-template-columns: 1fr; }
}

/* --- calendar nav --- */
.cal-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.cal-title {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
}
.nav-btn {
  border: 1px solid var(--rule);
  background: var(--panel);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  color: var(--ink);
}
.nav-btn:hover { background: var(--bg); }
.today-btn {
  width: auto;
  border-radius: 16px;
  padding: 0 12px;
  font-size: 12px;
  margin-left: auto;
}

/* --- calendar grid --- */
.calendar {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 3px 0 rgba(27, 36, 48, .06);
}
.grid-headers, .grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.grid-head {
  padding: 8px 10px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  color: #9A5A1E;
  background: #FFF3D6;
  border-bottom: 1px solid var(--rule);
}
.cell {
  min-height: 96px;
  padding: 17px 8px 6px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.cell:nth-child(7n) { border-right: none; }
.cell { position: relative; }
/* who has Leo that night */
.custody-strip {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 12px;
}
.cell.out-month { background: #FAFAF8; }
.cell.out-month .cell-day { color: #C6C9C3; }

.cell-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.cell-day {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}
.cell-day.today-badge {
  background: #E0752D;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cell-weather {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}
.cell-weather .lo { color: #A9AEAA; }

.cell-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chip {
  font-size: 11px;
  padding: 2px 5px;
  border-left: 2px solid;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.chip:hover { filter: brightness(0.97); }
.read-only .chip { cursor: default; }
.read-only .chip:hover { filter: none; }
.chip.is-override { border-left-width: 3px; }
.chip-time {
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
  margin-right: 4px;
}
.chip-more {
  font-size: 10px;
  color: var(--muted);
  padding-left: 5px;
}

/* --- color key under the calendar --- */
.color-key {
  margin-top: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .85);
  border: 1px solid var(--rule);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}
.key-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
}
.key-label {
  font-family: var(--display);
  font-weight: 600;
  color: #9A5A1E;
  margin-right: 2px;
}
.key-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink);
}
.key-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.key-swatch.is-bar { width: 22px; height: 10px; border-radius: 2px; }

/* --- override modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 36, 48, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--panel);
  border-radius: 18px;
  padding: 20px;
  width: 320px;
  max-width: 90vw;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
}
.modal-title {
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 14px;
}
.modal-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
}
.modal-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  background: var(--panel);
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  font-family: inherit;
}
.modal-option:hover { background: var(--bg); }
.modal-option.is-current { border-color: var(--sky); background: #EAF2F5; }
.modal-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.modal-clear, .modal-cancel {
  border: none;
  background: none;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  font-family: inherit;
}
.modal-clear:hover, .modal-cancel:hover { color: var(--ink); }

.loading, .error {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.reconnect-note {
  margin: 40px auto;
  max-width: 420px;
  padding: 24px;
  background: #fff;
  border-radius: 18px;
  border: 2px solid #E0752D66;
  color: var(--ink);
}
.reconnect-title {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  color: #E0752D;
  margin: 0 0 8px;
}

/* --- phone view (under 640px wide) ---
   Compact month grid with stripes + event dots, a tap-a-day detail card,
   and the most useful things first. Hidden on desktop. */
.cell-dots, .day-detail { display: none; }

@media (max-width: 640px) {
  .board {
    display: flex;
    flex-direction: column;
    padding: 16px 12px 120px;
  }
  .tally-panel { order: 5; margin-top: 10px; }
  .flag-note { order: 6; }
  .color-key { order: 7; }

  .cell {
    min-height: 56px;
    padding: 16px 2px 4px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .cell-top { justify-content: center; margin-bottom: 3px; }
  .cell-weather, .cell-events { display: none; }
  .cell-dots {
    display: flex;
    justify-content: center;
    gap: 3px;
    min-height: 6px;
  }
  .dot { width: 6px; height: 6px; border-radius: 50%; }
  .cell.is-selected { box-shadow: inset 0 0 0 2px #E0752D; background: #FFF3D6; }
  .grid-head { padding: 6px 0; text-align: center; font-size: 12px; }
  .cal-title { font-size: 20px; }

  .day-detail { display: block; margin-top: 10px; }
  .detail-custody {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    font-family: var(--display);
    font-weight: 600;
    font-size: 16px;
  }
  .detail-muted { color: var(--muted); font-size: 13px; margin: 0 0 8px; font-family: inherit; font-weight: 400; }
  .detail-events { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
  .chip.detail-chip {
    font-size: 14px;
    padding: 8px 10px;
    white-space: normal;
    border-left-width: 4px;
    border-radius: 6px;
  }
  .detail-chip .chip-time { display: inline-block; min-width: 64px; }

  .hero { padding: 16px 18px; }
  .hero-status { font-size: 28px; }
  .color-key { font-size: 11px; }
}
