:root {
  color-scheme: light;
  --font-sans: "DM Sans", "Segoe UI", sans-serif;
  --font-display: Newsreader, Georgia, serif;
  --bg: #f4f0e8;
  --surface: #fffdf8;
  --ink: #252923;
  --muted: #6f746c;
  --faint: #64765e;
  --line: #e4ddd0;
  --sage: #3e5346;
  --sage-soft: #e7eee8;
  --clay: #8c4d3a;
  --clay-soft: #f6e6df;
  --amber: #8a6230;
  --amber-soft: #f6ecd8;
  --rose: #8d4a4a;
  --rose-soft: #f8e8e6;
  --shadow: 0 10px 30px rgba(60, 46, 28, 0.06);
  --radius: 18px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: var(--sage); text-underline-offset: 0.15em; }
h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.025em; line-height: 0.98; color: var(--ink); }
h1 { font-size: 42px; margin: 0; }
h2 { font-size: 27px; line-height: 1.15; margin: 0.2rem 0 1.1rem; }

.app-shell { min-height: 100vh; }
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0 2rem;
  min-height: 74px;
  background: rgba(243, 239, 230, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand, .brand--on-story {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
}
.brand b { font-weight: 700; }
.brand__mark {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sage);
  color: #f7f3ea;
  font-family: var(--font-display);
}
.topnav { display: flex; justify-content: center; gap: 0.4rem; }
.nav-link, .tabbar a, .link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #5e655c;
  text-decoration: none;
  background: none;
  border: 0;
  font: inherit;
  font-size: 14px;
  padding: 0.85rem 0.7rem;
  cursor: pointer;
}
.nav-link { position: relative; height: 74px; }
.nav-link.is-active, .tabbar a.is-active { color: var(--ink); }
.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 30px;
  right: 10px;
  bottom: 0;
  height: 2px;
  background: #445744;
}
.container { width: min(980px, calc(100% - 2rem)); margin: 0 auto; padding: 56px 0 80px; }
.page-header { margin-bottom: 1.4rem; }
.page-header--row, .card__head, .callout, .cancel-row, .form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.lede, .muted, .hint { color: var(--muted); }
.lede { margin: 0.4rem 0 0; max-width: 40rem; }
.hint { display: block; margin-top: 0.35rem; font-size: 0.92rem; }
.hint--center { text-align: center; }
.back { color: var(--muted); text-decoration: none; }
.card, .form-card, .auth-card, .error-card, .people, .agenda-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card, .form-card { padding: 32px; margin-bottom: 20px; border-radius: 16px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.timeline, .list, .people, .agenda-cards, .thread-list, .bubbles { list-style: none; margin: 0; padding: 0; }
.timeline li + li, .list li + li { border-top: 1px solid var(--line); }
.timeline__link, .person-row, .agenda-card, .thread-list a {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  padding: 0.9rem 0;
  color: inherit;
  text-decoration: none;
}
.timeline__title, .person-row strong, .agenda-card strong { display: block; }
.timeline__when, .agenda-card__time { color: var(--muted); min-width: 9.5rem; }
.agenda-cards { display: grid; gap: 10px; }
.agenda-card {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 6px 14px;
  padding: 16px 18px;
  border-radius: 16px;
}
.agenda-card__time { min-width: 0; color: var(--faint); font-size: 13px; font-weight: 600; }
.agenda-card__body { display: grid; gap: 4px; }
.agenda-card strong { font-family: var(--font-sans); font-size: 16px; font-weight: 600; letter-spacing: 0; }
.day-group h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--ink); margin: 6px 0 12px; }
.lede { font-size: 15px; }
.page-header .btn { border-radius: 999px; font-weight: 600; padding: 10px 18px; }
.people { overflow: hidden; }
.person-row { padding: 0.95rem 1rem; }
.person-row + .person-row, .people li + li .person-row { border-top: 1px solid var(--line); }
.avatar {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sage-soft);
  color: var(--sage);
  font-weight: 600;
}
.avatar--lg { width: 4.2rem; height: 4.2rem; font-size: 1.2rem; }
.person-hero__row { display: flex; gap: 1rem; align-items: center; }
.tag, .badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 100px;
  padding: 5px 9px;
  background: #eeeae3;
  color: #6d675f;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
}
.badge--event, .badge--enabled, .tag-event, .tag-enabled, .badge-event, .badge-enabled { background: #e7ece3; color: #4d6249; }
.badge--task, .tag-task, .badge-task { background: #f6e4dc; color: #8d5340; }
.badge--reminder, .badge--pending, .tag-reminder, .tag-pending, .badge-reminder, .badge-pending { background: #f3ead6; color: #7d5a28; }
.badge--note, .badge--neutral, .tag-note, .tag-archived, .badge-note, .badge-archived { background: #eeeae3; color: #6d675f; }
.badge--blocked, .badge--cancelled, .tag-blocked, .tag-cancelled, .badge-blocked, .badge-cancelled { background: #f8e4e1; color: #8a4545; }
.badge--active, .tag-active, .badge-active { background: #e7ece3; color: #4d6249; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.timeline-list { display: grid; margin-top: 8px; }
.timeline {
  display: grid;
  grid-template-columns: 66px 22px minmax(0, 1fr);
  color: inherit;
  text-decoration: none;
}
.timeline__day { text-align: right; padding: 2px 10px 0 0; }
.timeline__day strong { display: block; font-size: 15px; font-weight: 600; line-height: 1.2; }
.timeline__day span { display: block; margin-top: 2px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; }
.timeline__line { position: relative; }
.timeline__line::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e4d9c9;
  transform: translateX(-50%);
}
.timeline:first-child .timeline__line::before { top: 8px; }
.timeline:last-child .timeline__line::before { bottom: auto; height: 16px; }
.timeline__line i {
  position: absolute;
  left: 50%;
  top: 7px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: #5c6b54;
}
.timeline__content { display: block; padding: 0 0 22px; }
.timeline__content .time { display: block; color: var(--faint); font-size: 12px; font-weight: 600; line-height: 1.2; }
.timeline__content strong {
  display: block;
  margin: 3px 0 5px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.35;
}
.timeline__meta { display: block; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.modal {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 0;
  border-radius: 28px;
  padding: 22px 28px 28px;
  background: var(--bg);
  box-shadow: 0 30px 80px rgba(37, 41, 35, 0.18);
}
.modal::backdrop { background: rgba(37, 41, 35, 0.28); }
.modal__close { position: sticky; top: 0; display: flex; justify-content: flex-end; margin: 0; background: transparent; }
.modal__close button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}
.modal h1 { font-size: 36px; }
.modal h2 { font-size: 22px; }
.modal .page-header { margin-bottom: 18px; }
.modal .form-card, .modal .card {
  box-shadow: none;
  border: 0;
  border-radius: 20px;
  padding: 28px;
  margin-bottom: 16px;
}
.modal label { color: var(--ink); font-size: 14px; font-weight: 600; }
.modal input, .modal select, .modal textarea {
  min-height: 48px;
  border-radius: 14px;
  border-color: #e6dfd4;
  background: #fff;
  padding: 12px 14px;
}
.modal .form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal .form-fields label { margin-bottom: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.3rem; }
.filters input, .filters select { width: auto; min-width: 11rem; background: var(--surface); }
label { display: block; margin: 0 0 0.9rem; color: var(--muted); font-size: 0.95rem; }
input, textarea, select, button { font: inherit; }
input, textarea, select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 6rem; resize: vertical; }
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  background: var(--sage);
  color: #f7f3ea;
  text-decoration: none;
  cursor: pointer;
}
.btn.secondary, button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger, .danger { background: transparent; color: var(--rose); border: 1px solid #efd4d0; }
.form-actions { justify-content: flex-end; margin-top: 0.4rem; }
.note, .callout, .success, .alert {
  border-radius: 14px;
  padding: 0.85rem 1rem;
}
.note { background: var(--sage-soft); color: var(--sage); }
.callout, .success { background: var(--amber-soft); }
.callout { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.alert { background: var(--rose-soft); color: var(--rose); }
.field-error { color: var(--rose); font-size: 0.9rem; }
.empty, .empty-state { color: var(--muted); }
.empty-state {
  padding: 1.3rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 252, 247, 0.6);
}
.detail { display: grid; grid-template-columns: 8rem 1fr; gap: 0.8rem 1rem; margin: 0; }
.detail dt { color: var(--faint); }
.detail dd { margin: 0; }
.cancel-row { margin-top: 1.5rem; }
.inbox {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 32rem;
  background: var(--surface);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.inbox__list { padding: 1rem; border-right: 1px solid var(--line); }
.thread-list a { border-radius: 12px; padding: 0.75rem; }
.thread-list a.is-active { background: var(--sage-soft); }
.inbox__list, .inbox__thread { min-height: 0; overflow: hidden; }
.inbox__thread { display: flex; flex-direction: column; padding: 1rem 1rem 0.8rem; background: #f7f3ea; }
.bubbles { display: grid; gap: 0.7rem; align-content: start; }
.bubble { max-width: 78%; }
.bubble p { margin: 0; padding: 0.8rem 0.9rem; border-radius: 16px; background: white; }
.bubble span { display: block; margin-top: 0.25rem; color: var(--faint); font-size: 0.8rem; }
.bubble--inbound { justify-self: end; text-align: right; }
.bubble--inbound p { background: #e5efe6; }
.inbox__lock { flex: 0 0 auto; margin: 0; padding: 12px 4px 2px; background: #f7f3ea; color: var(--faint); font-size: 13px; }
.thread-head { display: flex; align-items: center; gap: 0.75rem; flex: 0 0 auto; }
.thread-head .tag { margin-left: auto; }
.thread-scroll { flex: 1 1 0; min-height: 0; overflow: auto; }
.thread-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.75rem;
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
}
.thread-row.is-active { background: #e7f0e4; }
.thread-row__text { display: grid; min-width: 0; }
.thread-row__text span, .thread-row time { color: var(--faint); font-size: 0.85rem; }
.thread-row__text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.is-inbox { height: 100vh; overflow: hidden; }
body.is-inbox .container {
  height: calc(100vh - 74px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: 1rem;
  padding-bottom: 0;
  width: min(1120px, calc(100% - 2rem));
}
body.is-inbox .page-header { margin-bottom: 0.7rem; }
body.is-inbox .page-header h1 { font-size: 2.3rem; }
body.is-inbox .inbox { flex: 1; min-height: 0; height: auto; }
body.is-inbox .inbox__list { overflow: auto; }
.tabbar { display: none; }
.auth-page, .error-page { min-height: 100vh; background: var(--bg); }
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr; }
.auth-story {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem;
  background: linear-gradient(160deg, #e7eee8, #f3efe6 55%);
}
.auth-story h1 { font-size: clamp(3rem, 5vw, 4.6rem); max-width: 10ch; }
.auth-card, .error-card { margin: auto; width: min(420px, calc(100% - 2rem)); padding: 1.6rem; }
.auth-card h2 { font-size: 2.4rem; margin-bottom: 0.4rem; }
.auth-card button { width: 100%; }
.error-card { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);
}

@media (max-width: 800px) {
  .topnav { display: none; }
  .topbar { grid-template-columns: 1fr auto; }
  .split, .auth-layout, .inbox, .detail { grid-template-columns: 1fr; }
  .auth-story { min-height: 16rem; padding: 1.5rem; }
  .auth-story h1 { font-size: 2.6rem; }
  .page-header--row, .callout, .cancel-row { align-items: stretch; flex-direction: column; }
  .agenda-card, .modal .form-fields { grid-template-columns: 1fr; }
  .timeline { grid-template-columns: 52px 18px minmax(0, 1fr); }
  h1 { font-size: 34px; }
  .timeline__when, .agenda-card__time { min-width: 0; }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: #fffcf7;
    border-top: 1px solid var(--line);
  }
  .tabbar a { text-align: center; font-size: 0.82rem; }
  .container { padding-bottom: 5.5rem; }
  body.is-inbox .container { height: calc(100vh - 7.6rem); padding-bottom: 0; }
  body.is-inbox .inbox { grid-template-columns: 1fr; grid-template-rows: 12rem minmax(0, 1fr); }
  .inbox__list { border-right: 0; border-bottom: 1px solid var(--line); }
}
