/* Desktop top navigation is one stable shell. Home is the geometry source of truth. */
@media (min-width: 761px) {
  body:has(.page-shell) {
    --app-desktop-header-top: 1.75rem;
    --app-desktop-header-height: 4.25rem;
  }

  .desktop-sidebar {
    top: 2rem !important;
    right: var(--app-desktop-content-gutter) !important;
    left: var(--app-desktop-content-gutter) !important;
    display: flex !important;
    width: auto !important;
    height: 4.75rem !important;
    padding: 0 1rem !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .desktop-sidebar__nav {
    min-height: 4.75rem !important;
    align-items: center !important;
    justify-content: center !important;
    gap: clamp(1.1rem, 2.31vw, 2.64rem) !important;
  }

  .desktop-sidebar__link {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto !important;
    justify-items: center !important;
    align-content: center !important;
    gap: 0.09rem !important;
    min-width: 4.68rem !important;
    min-height: 3rem !important;
    padding: 0.37rem 0.64rem !important;
    border: 0;
    border-radius: 1.16rem !important;
    background: transparent;
    color: var(--app-muted-2);
    font-size: 0.86rem !important;
    font-weight: 680 !important;
    line-height: 1.08 !important;
    text-align: center !important;
  }

  .desktop-sidebar__link span:not(.desktop-sidebar__icon) {
    display: block;
    color: currentColor;
    line-height: 1.08;
  }

  .desktop-sidebar__link:not(.is-active) {
    background: transparent !important;
    color: var(--app-muted-2) !important;
    opacity: 1;
  }

  .desktop-sidebar__link.is-active {
    min-width: 4.9rem !important;
    min-height: 3.15rem !important;
    border: 0 !important;
    border-radius: 1.16rem !important;
    background: var(--app-primary-soft) !important;
    color: var(--app-primary-ink) !important;
  }

  .desktop-sidebar__icon,
  .desktop-sidebar__icon svg {
    width: 1.27rem !important;
    height: 1.27rem !important;
  }

  body:has(.page-shell) .desktop-sidebar {
    top: 2rem;
    right: var(--app-desktop-content-gutter);
    left: var(--app-desktop-content-gutter);
    display: flex;
    width: auto;
    height: 4.75rem;
    padding: 0 1rem;
    align-items: center;
    justify-content: center;
  }

  body:has(.page-shell) .desktop-sidebar__nav {
    min-height: 4.75rem;
    align-items: center;
    justify-content: center;
    gap: clamp(1.1rem, 2.31vw, 2.64rem);
  }

  body:has(.page-shell) .desktop-sidebar__link {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    justify-items: center;
    align-content: center;
    gap: 0.09rem;
    min-width: 4.68rem;
    min-height: 3rem;
    padding: 0.37rem 0.64rem;
    border: 0;
    border-radius: 1.16rem;
    background: transparent;
    color: var(--app-muted-2);
    font-size: 0.86rem;
    font-weight: 680;
    line-height: 1.08;
    text-align: center;
  }

  body:has(.page-shell) .desktop-sidebar__link span:not(.desktop-sidebar__icon) {
    display: block;
    color: currentColor;
    line-height: 1.08;
  }

  body:has(.page-shell) .desktop-sidebar__link:not(.is-active) {
    color: var(--app-muted-2);
    opacity: 1;
  }

  body:has(.page-shell) .desktop-sidebar__link.is-active {
    min-width: 4.9rem;
    min-height: 3.15rem;
    border: 0 !important;
    border-radius: 1.16rem;
    background: var(--app-primary-soft);
    color: var(--app-primary-ink);
  }

  body:has(.page-shell) .desktop-sidebar__icon,
  body:has(.page-shell) .desktop-sidebar__icon svg {
    width: 1.27rem;
    height: 1.27rem;
  }
}

/* Persistent web header: date, primary tabs, Inbox, and Settings stay visible on every app screen. */
.page-shell--dashboard .daily-card-section-heading__title-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: inherit;
  width: 100%;
  min-width: 0;
  color: inherit;
}

.page-shell--dashboard .daily-habits-panel__heading,
.page-shell--dashboard .daily-tasks-panel__heading {
  grid-template-columns: minmax(0, 1fr);
}

.page-shell--dashboard .daily-card-section-heading__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.42rem;
}

/* Home card count links match Calendar's pill and span the complete heading. */
.page-shell--dashboard .daily-habits-progress-pill,
.page-shell--dashboard .daily-tasks-open-pill,
.page-shell--dashboard .daily-calendar-events-pill {
  border: 0;
  border-radius: 999px;
  background: var(--app-primary-soft);
  color: var(--app-primary-ink);
  line-height: 1;
  white-space: nowrap;
}

.daily-dashboard__no-cards {
  display: grid;
  justify-items: start;
  gap: 0.45rem;
  padding: 1rem;
  border: 1px solid var(--app-line);
  border-radius: 1rem;
  background: var(--app-surface);
  color: var(--app-muted);
}

.daily-dashboard__no-cards a {
  color: var(--app-primary-ink);
  font-weight: 700;
}

@media (min-width: 761px) {
  .page-shell--dashboard .daily-dashboard__grid[data-card-count="1"] {
    grid-template-columns: minmax(0, 1fr);
    max-width: 42rem;
  }

  .page-shell--dashboard .daily-dashboard__grid[data-card-count="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 58rem;
  }

  .page-shell--dashboard .daily-dashboard__grid[data-card-count="0"] {
    grid-template-columns: minmax(0, 1fr);
    max-width: 42rem;
  }
}

/* Habit add affordances remain visible while their replacement view is being reworked. */
.habit-create-panel__summary {
  display: inline-grid;
  place-items: center;
  width: 2.125rem;
  min-width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  border: 1px solid var(--app-primary);
  border-radius: 8px;
  background: var(--app-primary);
  color: #fff;
  font-size: 1.45rem;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
}

.habit-create-panel__summary > span {
  line-height: 1;
}

.habits-list-titlebar__add {
  display: none;
}

@media (min-width: 761px) {
  .habits-list-titlebar__add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.8rem;
    padding: 0 1.1rem;
    border: 1px solid var(--app-primary);
    border-radius: 12px;
    background: var(--app-primary);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
  }
}

@media (min-width: 761px) {
  .desktop-sidebar.desktop-topbar,
  body:has(.page-shell) .desktop-sidebar.desktop-topbar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    z-index: 50;
    display: grid !important;
    grid-template-columns: minmax(13rem, 1fr) auto minmax(13rem, 1fr) !important;
    width: 100% !important;
    height: calc(var(--app-desktop-header-top) + var(--app-desktop-header-height)) !important;
    padding: var(--app-desktop-header-top) var(--app-desktop-content-gutter) 0 !important;
    border: 0 !important;
    border-top: 2px solid var(--app-primary) !important;
    border-bottom: 1px solid var(--app-line) !important;
    border-radius: 0 !important;
    background: var(--app-bg) !important;
    color: var(--app-ink) !important;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .desktop-topbar__date {
    align-self: center;
    justify-self: start;
    min-width: 0;
    color: var(--app-primary-ink);
    font-family: var(--app-display-font);
    font-size: clamp(1.62rem, 1.8vw, 1.95rem);
    font-weight: 780;
    letter-spacing: -0.03em;
    line-height: 1;
    white-space: nowrap;
  }

  .desktop-sidebar.desktop-topbar .desktop-sidebar__nav {
    grid-column: 2;
    align-self: center !important;
    min-height: var(--app-desktop-header-height) !important;
  }

  .desktop-topbar__actions {
    align-self: center;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.55rem;
  }

  .desktop-topbar__action {
    position: relative;
    display: grid;
    place-items: center;
    width: 2.45rem;
    height: 2.45rem;
    border: 1px solid var(--app-line);
    border-radius: 0.84rem;
    background: var(--app-surface);
    color: var(--app-muted-2);
    outline: 0;
    text-decoration: none;
  }

  .desktop-topbar__quick-add {
    border-color: color-mix(in srgb, var(--app-primary) 68%, var(--app-line));
    background: var(--app-primary);
    color: #fffdf8;
    font-size: 1.55rem;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
  }

  .desktop-topbar__action svg {
    width: 1.05rem;
    height: 1.05rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
  }

  .desktop-topbar__inbox-count {
    position: absolute;
    top: -0.38rem;
    right: -0.22rem;
    display: grid;
    place-items: center;
    min-width: 1.08rem;
    height: 1.08rem;
    padding: 0 0.2rem;
    border: 2px solid var(--app-bg);
    border-radius: 999px;
    background: var(--app-danger-soft);
    color: var(--app-danger);
    font-size: 0.66rem;
    font-weight: 850;
    line-height: 1;
  }

  /* Desktop date/actions belong to shared topbar. Hide Home's phone header too. */
  body:has(.page-shell--dashboard) .page-shell--dashboard .daily-dashboard__header {
    display: none !important;
  }

  .page-shell {
    padding-top: calc(var(--app-desktop-header-top) + var(--app-desktop-header-height) + 1.9rem) !important;
  }

  /* Shared topbar is the only web page header. Page-specific headers remain phone-only. */
  .page-shell .app-header {
    display: none !important;
  }
}

/* Shared date header stays on page surface; legacy app-header gradient must not leak in. */
.shared-workspace-header {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--app-ink);
}

.desktop-topbar__date-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.workspace-subheader {
  display: none;
}

/* Shared workspace quick add: Chores-style plus opens canonical creation choices. */
.shared-workspace-header .dashboard-add-button.chore-create-panel__summary,
.desktop-topbar__quick-add.chore-create-panel__summary {
  width: 2.125rem;
  min-width: 2.125rem;
  height: 2.125rem;
  min-height: 2.125rem;
  border: 1px solid color-mix(in srgb, var(--app-primary) 42%, var(--app-line));
  border-radius: 8px;
  background: var(--app-primary);
  color: #fffdf8;
}

.shared-workspace-header .dashboard-add-button.chore-create-panel__summary::before,
.shared-workspace-header .dashboard-add-button.chore-create-panel__summary::after,
.desktop-topbar__quick-add.chore-create-panel__summary::before,
.desktop-topbar__quick-add.chore-create-panel__summary::after {
  width: 0.72rem;
  height: 0.13rem;
}

.phone-header-utilities {
  display: none;
}

@media (max-width: 760px) {
  .page-shell:has(> .workspace-subheader) {
    gap: 1rem !important;
    padding-top: calc(env(safe-area-inset-top) + 0.35rem) !important;
  }

  .workspace-subheader {
    display: flex;
    align-items: center;
    min-height: 1.8rem;
    margin: 0 0 -0.75rem;
    padding-inline: 0.1rem;
  }

  .workspace-subheader h2 {
    margin: 0;
    color: #24211d;
    font-size: 1.28rem;
    font-weight: 850;
    letter-spacing: -0.02em;
    line-height: 1.1;
  }

  .page-shell--family .family-list-titlebar__copy {
    display: none !important;
  }

  .page-shell .shared-workspace-header.daily-dashboard__header.app-header {
    align-items: center;
    box-sizing: border-box;
    width: calc(100vw - 2.5rem);
    max-width: 100%;
    justify-self: center;
    min-height: 4.45rem;
    margin-bottom: 0;
    padding: 0.18rem 0 0.34rem;
  }

  .page-shell .shared-workspace-header .daily-dashboard__actions {
    gap: 0.5rem;
  }

  .shared-workspace-header .daily-dashboard__inbox,
  .shared-workspace-header .daily-dashboard__settings,
  .shared-workspace-header .workspace-create-button {
    box-sizing: border-box;
    flex: 0 0 auto;
  }

  .shared-workspace-header .daily-dashboard__inbox,
  .shared-workspace-header .daily-dashboard__settings,
  .page-shell--family:not(.is-editing-family-work) .family-app-header.shared-workspace-header .daily-dashboard__settings {
    width: 2.45rem;
    min-width: 2.45rem;
    height: 2.45rem;
    border-color: color-mix(in srgb, var(--app-muted-2) 32%, var(--app-line));
    border-radius: 0.84rem;
    background: var(--app-surface);
    color: var(--app-muted-2);
  }

  .shared-workspace-header .daily-dashboard__inbox svg,
  .shared-workspace-header .daily-dashboard__settings svg {
    width: 1.05rem;
    height: 1.05rem;
    stroke-width: 1.8;
  }

  .phone-header-utilities {
    display: contents;
  }

  .phone-header-action {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 2.125rem;
    min-width: 2.125rem;
    height: 2.125rem;
    min-height: 2.125rem;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--app-muted-2) 32%, var(--app-line));
    border-radius: 8px;
    background: var(--app-surface);
    color: var(--app-muted-2);
    text-decoration: none;
    line-height: 0;
  }

  .phone-header-action svg {
    display: block;
    width: 1.05rem;
    height: 1.05rem;
    margin: auto;
    stroke-width: 1.8;
  }

  .phone-header-inbox__count {
    position: absolute;
    top: -0.42rem;
    right: -0.28rem;
    display: grid;
    place-items: center;
    min-width: 1.08rem;
    height: 1.08rem;
    padding: 0 0.2rem;
    border: 2px solid var(--app-bg);
    border-radius: 999px;
    background: var(--app-danger-soft);
    color: var(--app-danger);
    font-size: 0.66rem;
    font-weight: 850;
    line-height: 1;
  }

  .chores-app-header .app-header__actions,
  .shopping-app-header .app-header__actions,
  .family-app-header .app-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
}

html:has(.quick-capture-dialog[open]),
body:has(.quick-capture-dialog[open]) {
  overflow: hidden;
}

body:has(.quick-capture-dialog[open]) > .desktop-topbar,
body:has(.quick-capture-dialog[open]) > .desktop-sidebar,
body:has(.quick-capture-dialog[open]) > .bottom-navigation,
body:has(.quick-capture-dialog[open]) > .page-shell {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.quick-capture-dialog[open] {
  position: fixed;
  inset: auto;
  top: 50%;
  left: 50%;
  z-index: 210;
  display: block;
  width: min(620px, calc(100vw - 2rem));
  max-width: none;
  max-height: min(86dvh, 560px);
  min-height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: 18px;
  background: var(--color-card);
  color: var(--color-ink);
  box-shadow: 0 24px 70px rgba(27, 39, 34, 0.22);
  transform: translate(-50%, -50%);
}

.quick-capture-dialog::backdrop {
  background: rgba(36, 49, 44, 0.35);
}

.quick-capture-dialog__sheet {
  display: grid;
  align-content: start;
  gap: 0.85rem;
  min-height: 0;
  padding: 1.45rem 1.55rem 1.55rem;
  background: var(--color-card);
}

.quick-capture-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0;
  border: 0;
}

.quick-capture-dialog__header h2 {
  margin: 0;
  color: var(--color-ink);
  font-size: 1.42rem;
  font-weight: 900;
  line-height: 1.1;
}

.quick-capture-dialog__close {
  appearance: none;
  display: inline;
  width: auto;
  min-width: 0;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #8b8375;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 780;
  line-height: 1.35;
  cursor: pointer;
}

.quick-capture-dialog__close:hover,
.quick-capture-dialog__close:focus-visible {
  color: var(--color-ink);
}

.quick-capture-options {
  display: grid;
  gap: 0.75rem;
  min-height: 0;
  overflow-y: auto;
}

.quick-capture-options__item {
  display: flex;
  align-items: center;
  min-height: 3.4rem;
  padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--color-line);
  border-radius: 13px;
  background: #fffefa;
  color: var(--color-ink);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 790;
  text-align: left;
  text-decoration: none;
}

.quick-capture-options__item:hover,
.quick-capture-options__item:focus-visible {
  border-color: var(--color-teal);
  background: var(--color-card);
  color: var(--color-ink);
}

@media (max-width: 760px) {
  body:has(.quick-capture-dialog[open]) > .bottom-navigation {
    display: none;
  }

  .quick-capture-dialog[open] {
    inset: auto 0 0;
    width: 100%;
    max-height: 88dvh;
    min-height: 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
    transform: none;
  }

  .quick-capture-dialog__sheet {
    gap: 1rem;
    padding: 1.55rem 1.35rem calc(2.25rem + env(safe-area-inset-bottom));
  }

  .quick-capture-dialog__header {
    align-items: flex-start;
  }

  .quick-capture-dialog__header h2 {
    font-size: 1.78rem;
  }

  .quick-capture-dialog__close {
    padding-top: 0.18rem;
  }

  .quick-capture-options__item {
    min-height: 3.7rem;
    padding: 0.82rem 0.95rem;
    font-size: 1.1rem;
  }
}

/* Final phone Chore footer inset: delete left, Save consumes remaining width. */
@media (max-width: 760px) {
  .page-shell--chores.is-editing-chore .chore-form--edit > .form-actions--with-delete {
    padding-right: 1.35rem;
    padding-left: 1.35rem;
  }
}

/* Chore checklist native clock stays at the entry field's trailing edge. */
.page-shell--chores .chore-checklist-editor__row input[type="time"]::-webkit-calendar-picker-indicator {
  margin-inline-start: auto;
  margin-inline-end: 0;
}

/* Calendar OAuth is a primary action on every host, including installed mobile apps. */
.calendar-connect-action,
.calendar-connect-action:visited {
  border-color: var(--color-teal-dark);
  background: var(--color-teal);
  color: #fff;
  opacity: 1;
}

.calendar-connect-action:hover,
.calendar-connect-action:focus-visible {
  border-color: var(--color-teal-dark);
  background: var(--color-teal-dark);
  color: #fff;
}
