:root {
  --bg: #f3eee6;
  --bg-deep: #ebe4d8;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --faint: #a8a29e;
  --line: #e7e2d8;
  --line-strong: #d6d0c4;
  --accent: #007aff;
  --accent-soft: #e8f1ff;
  --now: #ff3b30;
  --shadow: 0 18px 50px rgba(28, 25, 23, 0.08);
  --radius: 28px;
  --radius-sm: 16px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    system-ui, sans-serif;
  --hour-h: 52px;
  --gutter: 4.5rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  color-scheme: light;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.app {
  min-height: 100dvh;
  padding: 1rem 1.15rem 1.15rem;
  display: flex;
  flex-direction: column;
}

.shell {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.1rem 1.6rem 0.85rem;
  flex-wrap: wrap;
}

.brand-block {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  min-width: 0;
}

.brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(1.65rem, 2.1vw, 2.05rem);
  letter-spacing: -0.02em;
  line-height: 1;
}

.today-date {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.35vw, 1.25rem);
  font-weight: 500;
  white-space: nowrap;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem;
  background: #f4f1ea;
  border-radius: 999px;
}

.tabs a {
  padding: 0.42rem 1.05rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--muted);
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a.is-active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.1);
}

.status {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  margin-left: auto;
}

.weather {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.98rem;
  white-space: nowrap;
}

.weather .temp {
  color: var(--ink);
  font-weight: 650;
  font-size: 1.15rem;
}

.weather .hi-lo {
  color: var(--muted);
}

.weather svg {
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
}

.clock {
  font-size: clamp(1.7rem, 2.6vw, 2.35rem);
  font-weight: 720;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.35rem 1.4rem 1.25rem;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.page-kicker {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
}

.week-range {
  font-weight: 500;
  color: var(--faint);
}

.pill-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pill-nav button {
  border: 0;
  background: #f3f0ea;
  border-radius: 999px;
  min-width: 2.4rem;
  height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.pill-nav button.today-btn {
  padding: 0 1rem;
  font-weight: 650;
}

.pill-nav button:hover {
  background: var(--bg-deep);
}

.week-board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: auto;
  background: #fff;
}

.week-head,
.week-allday,
.week-body {
  display: grid;
  grid-template-columns: var(--gutter) repeat(7, minmax(7.5rem, 1fr));
  min-width: 58rem;
}

.week-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.day-head {
  text-align: center;
  padding: 0.7rem 0.4rem 0.55rem;
}

.day-head .dow {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.day-head .dom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.05rem;
  height: 2.05rem;
  margin-top: 0.2rem;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 650;
}

.day-head.is-today .dow {
  color: var(--accent);
}

.day-head.is-today .dom {
  background: var(--accent);
  color: #fff;
}

.gutter-cell {
  border-right: 1px solid var(--line);
}

.week-allday {
  border-bottom: 1px solid var(--line);
  min-height: 2.15rem;
}

.allday-label {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 0.5rem 0.35rem;
  font-size: 0.68rem;
  color: var(--faint);
}

.allday-slot,
.day-col {
  position: relative;
  border-left: 1px solid var(--line);
}

.allday-slot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.28rem 0.3rem;
  min-height: 2.15rem;
}

.allday-slot.is-today,
.day-col.is-today {
  background: var(--accent-soft);
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 0.12rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 650;
  background: #ececf0;
  color: #3a3a3c;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-body {
  position: relative;
  flex: 1;
}

.day-col {
  min-height: 0;
}

.hour-row {
  display: contents;
}

.hour-label {
  height: var(--hour-h);
  transform: translateY(-0.55em);
  text-align: right;
  padding-right: 0.55rem;
  font-size: 0.72rem;
  color: var(--faint);
  font-weight: 550;
}

.hour-slot {
  height: var(--hour-h);
  border-top: 1px solid var(--line);
}

.event {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 7px;
  padding: 0.28rem 0.4rem 0.2rem;
  overflow: hidden;
  border-left: 3px solid currentColor;
  background: #e8f1ff;
  color: #1e3a5f;
  z-index: 1;
}

.event .title {
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1.2;
}

.event .meta {
  font-size: 0.68rem;
  opacity: 0.8;
  margin-top: 0.08rem;
}

.event.color-blue {
  background: #e7f0ff;
  color: #1d4f91;
}
.event.color-green {
  background: #e5f6ea;
  color: #1b5e2f;
}
.event.color-orange {
  background: #fff1dd;
  color: #8a4b00;
}
.event.color-purple {
  background: #f3e8ff;
  color: #6b21a8;
}
.event.color-indigo {
  background: #e8eaff;
  color: #3730a3;
}
.event.color-teal {
  background: #dcf5f3;
  color: #115e59;
}
.event.color-rose {
  background: #ffe4e8;
  color: #9f1239;
}
.event.color-slate {
  background: #eeeef0;
  color: #3f3f46;
}

.chip.color-blue {
  background: #e7f0ff;
  color: #1d4f91;
}
.chip.color-green {
  background: #e5f6ea;
  color: #1b5e2f;
}
.chip.color-orange {
  background: #fff1dd;
  color: #8a4b00;
}
.chip.color-purple {
  background: #f3e8ff;
  color: #6b21a8;
}
.chip.color-indigo {
  background: #e8eaff;
  color: #3730a3;
}
.chip.color-teal {
  background: #dcf5f3;
  color: #115e59;
}
.chip.color-rose {
  background: #ffe4e8;
  color: #9f1239;
}
.chip.color-slate {
  background: #eeeef0;
  color: #3f3f46;
}

.now-line {
  position: absolute;
  left: var(--gutter);
  right: 0;
  grid-column: 1 / -1;
  grid-row: 1;
  height: 2px;
  background: var(--now);
  z-index: 2;
  pointer-events: none;
}

.now-line::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--now);
}

.placeholder-page,
.meals-page,
.homes-main {
  flex: 1;
  min-height: 0;
}

body.page-move .app {
  padding: 0;
  min-height: 100vh;
}

body.page-move .shell {
  border-radius: 0;
  box-shadow: none;
  min-height: 100vh;
}

body.page-move .topbar {
  flex-shrink: 0;
}

.homes-main {
  padding: 0;
  position: relative;
}

.homes-frame {
  display: block;
  width: 100%;
  height: calc(100vh - var(--nav-h, 5.5rem));
  border: none;
  background: var(--card);
}

.homes-fallback {
  margin: 0;
  min-height: calc(100vh - var(--nav-h, 5.5rem));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  color: var(--muted);
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  font-weight: 550;
  text-align: center;
}

.homes-frame[hidden],
.homes-fallback[hidden] {
  display: none !important;
}

.hero-card,
.meal-card {
  background: #faf8f4;
  border: 1px solid var(--line);
  border-radius: 20px;
}

.hero-card {
  max-width: 42rem;
  padding: 1.6rem 1.7rem 1.7rem;
}

.hero-card h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.7rem, 2.4vw, 2.15rem);
  letter-spacing: -0.03em;
}

.hero-card p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
}

.hero-card .tag {
  display: inline-block;
  margin-bottom: 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.meals-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(9.5rem, 1fr));
  gap: 0.7rem;
  overflow: auto;
  padding-bottom: 0.4rem;
}

.meal-card {
  padding: 0.95rem 0.9rem 1.05rem;
  min-width: 9.5rem;
}

.meal-card.is-today {
  background: var(--accent-soft);
  border-color: #c9ddff;
}

.meal-card .dow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.meal-card.is-today .dow {
  color: var(--accent);
}

.meal-card .dom {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0.15rem 0 0.75rem;
}

.meal {
  margin-top: 0.7rem;
}

.meal dt {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.meal dd {
  margin: 0.18rem 0 0;
  font-weight: 600;
  line-height: 1.3;
}

.meals-note {
  margin: 0 0 0.85rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .app {
    padding: 0.55rem;
  }

  .shell {
    border-radius: 20px;
  }

  .topbar {
    padding: 0.9rem 0.9rem 0.55rem;
  }

  .brand-block {
    flex-wrap: wrap;
    width: 100%;
  }

  .tabs {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  .tabs a {
    flex: 1;
    text-align: center;
  }

  .status {
    margin-left: 0;
  }

  .clock {
    font-size: 1.45rem;
  }

  .today-date {
    white-space: normal;
  }

  main {
    padding: 0.2rem 0.8rem 0.9rem;
  }

  .meals-grid {
    grid-template-columns: 1fr;
  }

  .meal-card {
    min-width: 0;
  }
}

@media (min-width: 1400px) {
  :root {
    --hour-h: 56px;
  }
}

@media (min-width: 1800px) {
  :root {
    --hour-h: 62px;
  }

  .app {
    padding: 1.15rem 1.35rem 1.3rem;
  }
}
