/* Self-hosted so first paint never waits on a third-party request: the old
   Google Fonts @import render-blocked the whole stylesheet on a cross-origin
   fetch the service worker can't cache. Latin subset of the variable font;
   its unicode-range covers ↑/↓, everything else falls back to system fonts. */
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("/static/figtree-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #f5ead8;
  --panel: #ebddc5;
  --text: #201e1d;
  --muted: #645c50;
  --line: color-mix(in srgb, #201e1d 16%, transparent);
  --quiet-awake: #9a8bb8;
  --active-awake: #7c68a4;
  --light-sleep: #8496bc;
  --deep-sleep: #6e7fae;
  --agitated: #aa5f72;
  --away: #9c8e77;
  --chart-asleep: #6e7fae;
  --chart-awake-crib: #9a8bb8;
  --chart-track: #f9f4ed;
  --chart-ink: #2e2b25;
  --chart-muted: #82796a;
  --chart-wake-label: #645c50;
  --chart-total: oklch(0.34 0.07 264);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Figtree", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
main {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}
.status {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.state-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 92px;
}
.state-dot {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 50%;
  background: var(--away);
  box-shadow: inset 0 0 0 10px rgb(255 255 255 / 0.38);
}
.state {
  margin: 0;
  font-size: 42px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.observed {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}
.history {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--panel);
}
.history-header,
.event {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 0.7fr) minmax(170px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
}
.history-header {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}
.event + .event { border-top: 1px solid var(--line); }
.week { margin-top: 24px; }
.week-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.week-axis {
  position: sticky;
  left: 0;
  z-index: 6;
  flex: none;
  width: 42px;
  background: var(--bg);
}
.week-axis-inner {
  position: relative;
  height: 470px;
  margin-top: 40px;
}
.week-tick {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--chart-muted);
  white-space: nowrap;
}
.week-day {
  flex: 1 1 0;
  min-width: 72px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.week-day-head {
  text-align: center;
  height: 32px;
}
.week-day-short {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--chart-ink);
}
.week-day-date {
  font-size: 10px;
  font-weight: 500;
  color: var(--chart-muted);
}
.week-track {
  position: relative;
  height: 470px;
  background: var(--chart-track);
  border-radius: 14px;
}
.week-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: color-mix(in srgb, var(--chart-ink) 10%, transparent);
  pointer-events: none;
}
.week-hour-line-major {
  background: rgb(212 208 202);
}
.week-block {
  position: absolute;
  left: 9%;
  width: 82%;
  background: var(--chart-asleep);
  border-radius: 10px;
  overflow: hidden;
}
.week-block-cut-top { border-radius: 0 0 10px 10px; }
.week-block-cut-bottom { border-radius: 10px 10px 0 0; }
.week-block-cut-top.week-block-cut-bottom { border-radius: 0; }
.week-band {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--chart-awake-crib);
}
.week-block-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
.week-wake-label {
  position: absolute;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
  color: var(--chart-wake-label);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}
.week-dim {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-radius: 0 0 14px 14px;
  z-index: 3;
}
.week-now-line {
  position: absolute;
  left: -3px;
  right: -3px;
  height: 2px;
  margin-top: -1px;
  background: var(--text);
  border-radius: 2px;
  z-index: 4;
}
.week-now-dot {
  position: absolute;
  left: -7px;
  width: 9px;
  height: 9px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--text);
  z-index: 5;
}
.week-now-status {
  position: absolute;
  left: -6px;
  right: -6px;
  padding-top: 5px;
  text-align: center;
  font-size: 8.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  z-index: 5;
}
.week-day-total {
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--chart-total);
}
.event-state { font-weight: 700; }
.group-state {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.toggle {
  display: inline-block;
  width: 18px;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}
.toggle-placeholder {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.event-duration { color: var(--text); font-weight: 600; }
.event-time { color: var(--muted); }
.event-detail {
  display: none;
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  padding: 0 18px 14px 54px;
}
.event.expanded .event-detail {
  display: block;
}
.detail-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(100px, 0.6fr) minmax(150px, 1fr);
  gap: 14px;
  padding-top: 6px;
}
.empty {
  padding: 18px;
  color: var(--muted);
}
@media (max-width: 560px) {
  main { width: min(100% - 20px, 920px); padding: 16px 0; }
  .status { padding: 20px; }
  .observed-sep { display: none; }
  .observed-crib { display: block; }
  .state-row { align-items: flex-start; min-height: 0; }
  .state-dot { width: 48px; height: 48px; flex-basis: 48px; }
  .state { font-size: 30px; }
  .history-header, .event { grid-template-columns: 1fr; gap: 6px; }
  .event-detail { padding-left: 54px; }
  .detail-row { grid-template-columns: 1fr; gap: 2px; }
}
