#home {
  --bg: #f6efe8;
  --elev: #fffcf8;
  --ink: #2a211f;
  --muted: #6f675f;
  --line: rgba(28, 25, 23, 0.12);
  --accent: #8d3d45;
  --accent-fg: #fbf6f2;
  --danger: #8a3d32;
  --radius-card: 24px;
  --radius-control: 8px;
  --pad: 16px;
  --nav: calc(64px + env(safe-area-inset-bottom));
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
}

#home.is-open {
  display: block !important;
  z-index: 1200;
}

.home-frame {
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top)) 16px var(--nav);
}

.home-top {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: end;
  gap: 8px;
  margin-bottom: 16px;
}

.home-titles { min-width: 0; }

.home-kicker {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

#homeHeading {
  font-family: Fraunces, "Times New Roman", serif;
  font-weight: 500;
  font-size: clamp(1.8rem, 1.2rem + 2vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.text-btn, .quiet-btn, .icon-btn, .home-nav button, .sheet-actions .primary, .note-form button, .danger-link {
  font: inherit;
  cursor: pointer;
}

.text-btn {
  background: none;
  border: 0;
  color: var(--ink);
  padding: 8px 0;
  min-height: 44px;
}

.home-top .text-btn:last-child { text-align: right; }

.home-status {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--muted);
  margin-bottom: 12px;
}

.pane {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: 12px;
}

.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.month-bar h2 {
  font-family: Fraunces, "Times New Roman", serif;
  font-weight: 500;
  font-size: 1.25rem;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--ink);
  display: grid;
  place-items: center;
}

.icon-btn svg { width: 20px; height: 20px; }

.weekday-row, .month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.weekday-row {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-bottom: 4px;
}

.day-cell {
  aspect-ratio: 1;
  border: 0;
  background: transparent;
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  cursor: pointer;
}

.day-cell.is-out { color: transparent; pointer-events: none; }
.day-cell.is-today { box-shadow: inset 0 0 0 1px var(--line); }
.day-cell.is-on { background: var(--accent); color: var(--accent-fg); }
.day-mark {
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0;
}
.day-cell.has-event .day-mark { opacity: 0.85; }

.calendar-note {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 14px;
}

.next-card {
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 28px;
  padding: 22px 20px 18px;
  margin-bottom: 14px;
}

.next-card button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.next-kicker {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.82;
  margin-bottom: 8px;
}

.next-card h2 {
  font-family: Fraunces, "Times New Roman", serif;
  font-weight: 500;
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 8px;
}

.next-when, .next-place {
  display: block;
  font-size: 15px;
  line-height: 1.4;
}

.next-place { opacity: 0.88; margin-top: 4px; }

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.week-strip button {
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 12px;
  min-height: 52px;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.week-strip .week-name { font-size: 11px; color: var(--muted); }
.week-strip .week-num { font-variant-numeric: tabular-nums; }
.week-strip button.is-on { background: var(--ink); color: var(--accent-fg); }
.week-strip button.is-on .week-name { color: inherit; opacity: 0.75; }
.week-strip button.has-event .week-num { box-shadow: inset 0 -2px 0 currentColor; }

.day-story-title {
  font-family: Fraunces, "Times New Roman", serif;
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  margin: 18px 0 8px;
}

.plan-line {
  color: var(--muted);
  margin-bottom: 8px;
}

.agenda { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }

.agenda-empty, .trip-empty, .thread-empty {
  color: var(--muted);
  padding: 8px 0 4px;
}

.event-card, .trip-card, .day-card, .bubble {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: var(--pad);
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}

.event-card, .trip-card, .day-card { cursor: pointer; }

.event-meta, .trip-meta, .bubble-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.event-card strong, .trip-card strong, .day-card strong {
  font-weight: 600;
  display: block;
}

.quiet-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.quiet-btn {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 12px;
  display: grid;
  place-items: center;
}

.home-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--line);
  max-width: 720px;
  margin: 0 auto;
}

.home-nav button {
  min-height: 44px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.home-nav button.on {
  background: var(--accent);
  color: var(--accent-fg);
}

.pane-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-lock { color: var(--muted); font-size: 13px; }

#thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}

.bubble { border-radius: 16px; }
.bubble.is-mine { margin-left: 18%; }
.bubble.is-theirs { margin-right: 18%; }

.bubble-remove {
  margin-top: 8px;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0;
  min-height: 32px;
}

.note-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.note-form textarea, .sheet-card input, .sheet-card textarea, .sheet-card select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--ink);
  border-radius: var(--radius-control);
  font: inherit;
  padding: 12px;
  min-height: 44px;
}

.note-form textarea { min-height: 52px; resize: none; }

.note-form button, .sheet-actions .primary {
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(28, 25, 23, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] { display: none !important; }

.sheet-card {
  width: min(640px, 100%);
  max-height: min(88vh, 760px);
  overflow: auto;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}

.sheet-card h2 {
  font-family: Fraunces, "Times New Roman", serif;
  font-weight: 500;
  font-size: 1.6rem;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.sheet-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.sheet-card label input,
.sheet-card label textarea,
.sheet-card label select { margin-top: 6px; color: var(--ink); }

.sheet-card textarea { min-height: 96px; resize: vertical; }

.sheet-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.sheet-error { color: var(--danger); margin-bottom: 10px; }
.danger-link {
  display: block;
  margin: 16px auto 0;
  background: none;
  border: 0;
  color: var(--danger);
  min-height: 44px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.trip-open { display: flex; flex-direction: column; gap: 8px; }
.back-line { margin-bottom: 8px; }

@media (prefers-reduced-motion: reduce) {
  #home, .sheet-card { scroll-behavior: auto; }
}
