@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/CormorantGaramond.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/SourceSans3.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --cream: #F3EBE0;
  --cream-deep: #E8DDD0;
  --paper: #FFFBF6;
  --card: #FFFcf8;
  --ink: #3A2F28;
  --ink-soft: #6A5A50;
  --ink-faint: #9A8B80;
  --line: #E4D8C8;
  --rose: #C4897C;
  --rose-deep: #B36F62;
  --rose-soft: #EED9D2;
  --sage: #7E9174;
  --gold: #C9A36A;
  --blush: #F6E8E1;
  --sticky: #F7E7B5;
  --sticky-ink: #5A4A28;
  --taylor: #C4897C;
  --austin: #5E8A84;
  --son: #D4A05A;
  --family: #8B7CA8;
  --filming: #C45C3E;
  --nav-w: 92px;
  --shadow: 0 1px 2px rgba(58, 47, 40, 0.04), 0 10px 28px rgba(58, 47, 40, 0.06);
  --radius: 20px;
  --font-serif: "Cormorant Garamond", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
  background-image:
    radial-gradient(ellipse at 12% 0%, rgba(196, 137, 124, 0.10), transparent 42%),
    radial-gradient(ellipse at 100% 100%, rgba(126, 145, 116, 0.10), transparent 40%);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
textarea { resize: vertical; }

#app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}

/* ---- Left nav ---- */
.nav {
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px 12px;
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 245, 0.55);
  user-select: none;
  -webkit-user-select: none;
}

.nav-mark {
  width: 42px;
  height: 42px;
  color: var(--rose);
  margin-bottom: 14px;
  opacity: 0.9;
}

.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  flex: 1;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  min-height: 62px;
  border-radius: 16px;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-btn svg { width: 22px; height: 22px; }
.nav-btn span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-btn:hover { background: rgba(58, 47, 40, 0.05); color: var(--ink); }
.nav-btn.is-active {
  background: var(--blush);
  color: var(--rose-deep);
}
.nav-settings { margin-top: auto; }

/* ---- Main ---- */
.main {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  padding: 22px 26px 20px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.view.is-active { display: flex; flex-direction: column; }
.view[hidden] { display: none !important; }

/* ---- Shared type ---- */
.page-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rose);
}
.page-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 42px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.section-title {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
}
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 12px; }
.example-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--rose-soft);
  color: var(--rose-deep);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.card {
  background: var(--paper);
  border: 1px solid rgba(58, 47, 40, 0.07);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.icon-btn, .text-btn, .primary-btn, .ghost-btn, .danger-btn {
  min-height: 40px;
  border-radius: 12px;
  padding: 0 14px;
  font-weight: 600;
  font-size: 14px;
}
.icon-btn {
  width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  background: rgba(58, 47, 40, 0.05);
}
.icon-btn:hover { background: rgba(58, 47, 40, 0.1); color: var(--ink); }
.primary-btn { background: var(--ink); color: #FBF6F0; }
.primary-btn:hover { background: #2a221c; }
.ghost-btn { background: transparent; color: var(--ink-soft); }
.ghost-btn:hover { background: rgba(58, 47, 40, 0.06); }
.danger-btn { color: #9A3B2F; background: rgba(196, 92, 62, 0.1); }
.text-btn { color: var(--rose-deep); }
.text-btn:hover { text-decoration: underline; }

/* ---- Home ---- */
.home {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.home-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 16px;
  position: relative;
  min-height: 92px;
}

.home-heading { position: relative; z-index: 1; }
.home-heading .page-title { margin-top: 2px; }
.home-greet {
  margin: 8px 0 0;
  font-size: 17px;
  color: var(--ink-soft);
}

.home-timeblock {
  text-align: right;
  position: relative;
  z-index: 1;
  padding-right: 8px;
}
.home-clock {
  font-family: var(--font-serif);
  font-size: 56px;
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.03em;
}
.home-date {
  margin-top: 6px;
  font-size: 15px;
  color: var(--ink-soft);
}

.floral {
  position: absolute;
  right: 200px;
  top: -28px;
  width: 220px;
  height: 130px;
  pointer-events: none;
  opacity: 0.72;
  color: var(--rose);
}

.home-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.9fr 1fr;
  gap: 16px;
  min-height: 0;
}

.home-card {
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.home-card .section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

.event-list, .chore-list, .meal-list, .grocery-list, .content-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  min-height: 0;
}
.event-item {
  display: grid;
  grid-template-columns: 64px 8px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.event-item:last-child { border-bottom: 0; }
.event-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  padding-top: 3px;
}
.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  background: var(--who, var(--family));
}
.event-title { font-weight: 600; font-size: 15px; }
.event-who { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
.empty-line { color: var(--ink-faint); font-size: 14px; padding: 8px 0; }

.dinner-name {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.15;
  margin: 6px 0 8px;
}
.dinner-note { color: var(--ink-soft); font-size: 14px; }

.sticky-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), transparent 28%),
    var(--sticky);
  border: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.5) inset, var(--shadow);
  color: var(--sticky-ink);
}
.sticky-card .section-title { color: var(--sticky-ink); }
.sticky-input {
  flex: 1;
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 16px;
  line-height: 1.45;
  min-height: 0;
  font-family: var(--font-sans);
  color: var(--sticky-ink);
}

.weather {
  padding: 14px 16px 12px;
}
.weather-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.weather-loc { font-size: 12px; color: var(--ink-faint); }
.weather-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.weather-day {
  text-align: center;
  padding: 8px 4px 10px;
  border-radius: 14px;
}
.weather-day.is-today { background: var(--blush); }
.weather-day .wd { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.weather-day svg { width: 28px; height: 28px; margin: 6px auto 4px; display: block; color: var(--ink); }
.weather-day .temps { font-size: 13px; font-weight: 600; }
.weather-day .lo { color: var(--ink-faint); font-weight: 500; }
.weather-status { font-size: 13px; color: var(--ink-soft); padding: 8px 0 4px; }

/* ---- Calendar ---- */
.cal-wrap { height: 100%; display: flex; flex-direction: column; gap: 14px; }
.cal-head, .page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-range {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  min-width: 210px;
  text-align: center;
}
.week {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  min-height: 0;
}
.day-col {
  background: var(--paper);
  border: 1px solid rgba(58, 47, 40, 0.07);
  border-radius: 16px;
  padding: 10px 8px 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.day-col.is-today { border-color: var(--rose-soft); box-shadow: 0 0 0 2px rgba(196, 137, 124, 0.18); }
.day-col-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 4px 8px;
}
.day-name { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.day-num { font-family: var(--font-serif); font-size: 24px; font-weight: 600; line-height: 1; }
.day-events { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.chip {
  border: 0;
  border-radius: 10px;
  padding: 7px 8px;
  text-align: left;
  background: color-mix(in srgb, var(--who, var(--family)) 18%, white);
  color: var(--ink);
  min-height: 44px;
  width: 100%;
}
.chip-time { display: block; font-size: 10px; font-weight: 600; color: var(--ink-soft); }
.chip-title { display: block; font-size: 13px; font-weight: 600; line-height: 1.25; }
.day-add {
  margin-top: 6px;
  width: 100%;
  min-height: 36px;
  border-radius: 10px;
  color: var(--ink-faint);
  font-weight: 600;
  font-size: 13px;
}
.day-add:hover { background: rgba(58, 47, 40, 0.05); color: var(--ink); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.legend i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--who); display: inline-block;
}

/* ---- Chores ---- */
.chores-wrap { height: 100%; display: flex; flex-direction: column; gap: 14px; }
.star-counter {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--blush);
  border-radius: 999px;
  padding: 8px 16px 8px 12px;
  font-weight: 600;
}
.star-counter svg { width: 22px; height: 22px; color: var(--gold); fill: var(--gold); }
.star-counter strong { font-family: var(--font-serif); font-size: 28px; font-weight: 600; line-height: 1; display: inline-block; min-width: 0.8em; }
.star-counter span { font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); position: relative; top: -2px; }
.chore-cols {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  min-height: 0;
}
.chore-col {
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chore-col h3 { margin: 0 0 12px; font-family: var(--font-serif); font-size: 24px; font-weight: 600; }
.chore-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 4px;
  min-height: 48px;
  border-radius: 12px;
  border-bottom: 1px solid var(--line);
}
.chore-row:last-child { border-bottom: 0; }
.chore-row.is-done .chore-label { text-decoration: line-through; color: var(--ink-faint); }
.check {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  border: 1.6px solid var(--gold);
  display: grid;
  place-items: center;
  color: transparent;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.chore-row.is-done .check {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}
.check svg { width: 14px; height: 14px; }
.chore-label { flex: 1; font-size: 16px; font-weight: 500; }
.chore-del {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--ink-faint);
  font-size: 18px;
}
.chore-del:hover { background: rgba(154, 59, 47, 0.1); color: #9A3B2F; }
.chore-add {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.chore-add input, .field input, .field textarea, .field select, .add-row input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  min-height: 42px;
}
.chore-add input:focus, .field input:focus, .field textarea:focus, .add-row input:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(196, 137, 124, 0.2);
}

.star-pop {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  font-size: 28px;
  color: var(--gold);
  animation: star-float 0.7s ease-out forwards;
  filter: drop-shadow(0 2px 4px rgba(201, 163, 106, 0.4));
}
@keyframes star-float {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  25% { transform: translate(-50%, -70%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -140%) scale(0.8); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .star-pop { animation: none; opacity: 0; }
}

/* ---- Meals & Content ---- */
.split {
  flex: 1;
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 16px;
  min-height: 0;
}
.panel {
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.meal-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.meal-row:last-child { border-bottom: 0; }
.meal-row.is-today .meal-day { color: var(--rose-deep); }
.meal-day { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.meal-row input {
  border: 0;
  background: transparent;
  min-height: 40px;
  padding: 6px 4px;
  border-radius: 8px;
  width: 100%;
}
.meal-row input:focus { background: rgba(58, 47, 40, 0.04); outline: none; }

.grocery-item, .content-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  min-height: 44px;
}
.grocery-item.is-done span { text-decoration: line-through; color: var(--ink-faint); }
.gcheck {
  width: 22px; height: 22px; flex: 0 0 22px;
  border-radius: 6px;
  border: 1.6px solid var(--sage);
  display: grid; place-items: center;
  color: transparent;
}
.grocery-item.is-done .gcheck { background: var(--sage); color: #fff; border-color: var(--sage); }
.gcheck svg { width: 12px; height: 12px; }
.add-row { display: flex; gap: 8px; margin-top: 12px; }
.item-del { margin-left: auto; color: var(--ink-faint); width: 32px; height: 32px; border-radius: 8px; }
.item-del:hover { color: #9A3B2F; background: rgba(154, 59, 47, 0.08); }

/* ---- Modal ---- */
.modal-root, .settings {
  position: fixed;
  z-index: 40;
}
.modal-root {
  inset: 0;
  background: rgba(42, 33, 28, 0.35);
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-root[hidden], .settings[hidden], .settings-backdrop[hidden], .sleep[hidden] { display: none !important; }
.modal {
  width: min(520px, 100%);
  background: var(--paper);
  border-radius: 22px;
  padding: 22px 24px 18px;
  box-shadow: 0 24px 60px rgba(42, 33, 28, 0.22);
}
.modal h2 { margin: 0 0 16px; font-family: var(--font-serif); font-size: 28px; font-weight: 600; }
.fields { display: flex; flex-direction: column; gap: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; }
.who-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.who-pill {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  font-weight: 600;
  font-size: 14px;
  background: #fff;
}
.who-pill.is-on {
  border-color: transparent;
  background: color-mix(in srgb, var(--who) 22%, white);
  box-shadow: inset 0 0 0 2px var(--who);
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-actions .danger-btn { margin-right: auto; }

/* ---- Settings ---- */
.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(42, 33, 28, 0.2);
}
.settings {
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: var(--paper);
  box-shadow: -12px 0 40px rgba(42, 33, 28, 0.12);
  padding: 22px 22px 16px;
  z-index: 50;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.settings-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-shrink: 0; }
.settings h2 { margin: 0; font-family: var(--font-serif); font-size: 32px; font-weight: 600; }
.settings-note { color: var(--ink-soft); font-size: 14px; margin: 6px 0 12px; flex-shrink: 0; }
.settings-scroll { flex: 1; overflow: auto; min-height: 0; padding-right: 4px; }
.settings .fields { margin-bottom: 8px; }
.latlon { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); flex-shrink: 0; }
.sleep-ampm {
  font-size: 0.28em;
  margin-left: 0.15em;
  letter-spacing: 0.08em;
  position: relative;
  top: -0.55em;
  font-family: var(--font-sans);
  font-weight: 600;
}

/* ---- Sleep ---- */
.sleep {
  position: fixed;
  inset: 0;
  z-index: 70;
  background:
    radial-gradient(ellipse at 50% 20%, #3A2C24, #1C1512 70%);
  color: #F3EBE0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
}
.sleep-kicker {
  margin: 0;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  color: #C4897C;
}
.sleep-clock {
  font-family: var(--font-serif);
  font-size: clamp(96px, 18vw, 180px);
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.04em;
  margin: 12px 0 8px;
}
.sleep-date { font-size: 22px; color: #D9CBBE; }
.sleep-next { margin-top: 28px; font-size: 18px; color: #E8DDD0; max-width: 640px; padding: 0 24px; }
.sleep-hint { margin-top: 48px; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: #9A8B80; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink);
  color: #FBF6F0;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

/* Landscape iPad targeting 1024–1366 */
@media (max-width: 1100px) {
  .page-title { font-size: 36px; }
  .home-clock { font-size: 48px; }
  .floral { right: 170px; width: 180px; }
  .dinner-name { font-size: 28px; }
}
@media (orientation: portrait) {
  body::after {
    /* The app is designed for landscape; keep it usable if rotated. */
  }
  .home-grid, .chore-cols, .split, .week { grid-template-columns: 1fr; }
}
