/* Final Tasks filters and sheet-scroll contract: phone keeps filters visible, web keeps them right-aligned. */
@media (max-width: 760px) {
  .page-shell--tasks:not(.is-creating-task):not(.is-editing-task) .tasks-list-titlebar {
    display: flex;
    justify-content: flex-end;
    min-height: 2.1rem;
    margin: 0 0 1rem;
  }

  .page-shell--tasks:not(.is-creating-task):not(.is-editing-task) .tasks-list-titlebar__copy,
.page-shell--tasks:not(.is-creating-task):not(.is-editing-task) .tasks-list-titlebar__add {
    display: none;
  }

  .page-shell--tasks .tasks-list-titlebar__controls {
    display: flex;
    width: 100%;
    justify-content: flex-end;
  }

  .page-shell--tasks:not(.is-creating-task):not(.is-editing-task) .tasks-filter.segmented {
    width: 100%;
    max-width: none;
  }
}

/* Family task rows open the same canonical Task sheet used by Home, Tasks, and Inbox. */
.page-shell--family.is-editing-task::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(36, 49, 44, 0.38);
  backdrop-filter: blur(2px);
}

.page-shell--family.is-editing-task .sheet-backdrop-cancel--task {
  position: fixed;
  inset: 0;
  z-index: 56;
  display: block;
  color: transparent;
  text-decoration: none;
}

@media (min-width: 761px) {
  /* The inert list keeps its document geometry behind the fixed editor. */
  .page-shell--tasks:is(.is-creating-task, .is-editing-task) .tasks-list-panel {
    max-height: none;
    overflow: visible;
  }

  .page-shell--tasks:not(.is-creating-task):not(.is-editing-task) .tasks-list-titlebar__controls {
    justify-content: flex-end;
  }
.page-shell--tasks.is-editing-task .task-edit-panel,
.page-shell--tasks.is-creating-task .task-create-page,
.page-shell--inbox.is-editing-task .task-edit-panel {
    overflow-y: auto;
    scroll-padding-bottom: 5.75rem;
  }
.page-shell--tasks.is-editing-task .task-form--edit > .form-actions,
.page-shell--tasks.is-creating-task .task-form--compact-modal > .form-actions,
.page-shell--inbox.is-editing-task .task-form--edit > .form-actions {
    position: static !important;
    right: auto;
    bottom: 0;
    left: auto;
    z-index: 12;
    margin: 0.85rem 0 0;
    background: var(--color-card);
    filter: none;
  }
.page-shell--tasks.is-editing-task .task-form--edit > .form-actions,
.page-shell--inbox.is-editing-task .task-form--edit > .form-actions {
    padding-left: 5.4rem;
  }
}
.daily-task-row__copy,
.work-assignment-status {
  min-width: 0;
}

.daily-task-row__copy {
  display: grid;
  gap: 0.12rem;
}
:is(.page-shell--family) .daily-task-subtask-preview__copy,
.task-subtask-preview__copy {
  display: grid;
  width: 100%;
  max-width: 100%;
  gap: 0.08rem;
  min-width: 0;
  line-height: 1.18;
}

.daily-task-subtask-preview__title,
.task-subtask-preview__title,
.daily-task-subtask-preview__due,
.task-subtask-preview__due {
  min-width: 0;
  overflow-wrap: anywhere;
}

.work-title-copy:has(.work-title__content) {
  display: grid;
  grid-template-columns: 1.125rem minmax(0, 1fr);
  align-items: start;
  column-gap: 0.375rem;
}

.work-title__emoji,
.work-title__text {
  min-width: 0;
}

.work-title__emoji {
  grid-column: 1;
  font-size: 1.125rem;
  line-height: 1.2;
}

.work-title__content {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}
:is(.page-shell--family) :is( .daily-task-row).has-details {
  row-gap: 0.38rem;
  padding-block: 0.52rem;
}
:is(.page-shell--family) .daily-task-row.has-details.has-subtasks {
  padding-block: 0.68rem 0.78rem;
}
:is(.page-shell--family) .daily-task-row.has-details.has-subtasks .daily-work-details {
  margin-bottom: 0.52rem;
}

.daily-work-details {
  display: grid;
  grid-column: 2;
  gap: 0.38rem;
  min-width: 0;
}
:is(.page-shell--family) .daily-task-row .daily-work-details {
  margin-inline-start: 1.5rem;
}
:is(.page-shell--family) .daily-task-row .daily-task-subtask-preview,
.personal-task-row > .task-subtask-preview {
  margin-inline-start: 1.5rem;
}

.personal-task-row > .task-row__url {
  margin-inline-start: 1.5rem;
}

.daily-work-note {
  min-width: 0;
  color: var(--app-muted);
  font-size: 0.78rem;
  font-weight: var(--font-weight-strong);
  line-height: 1.3;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.daily-work-url {
  min-width: 0;
  color: var(--app-primary-ink);
  font-size: 0.76rem;
  font-weight: var(--font-weight-strong);
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.work-assignment-status {
  overflow: hidden;
  color: var(--color-muted);
  font-size: 0.76rem;
  font-weight: var(--font-weight-strong);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.completed-subtasks-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.42rem;
  min-height: 2rem;
  width: fit-content;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--tasks-muted, var(--app-muted));
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: var(--font-weight-strong);
  line-height: 1.2;
}

.completed-subtasks-toggle[hidden] {
  display: none;
}

[data-completed-subtask-item][hidden] {
  display: none;
}

.completed-subtasks-toggle__chevron {
  width: 0.48rem;
  height: 0.48rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 160ms ease;
}

.completed-subtasks-toggle[aria-expanded="true"] .completed-subtasks-toggle__chevron {
  transform: rotate(225deg) translate(-1px, -1px);
}

.completed-subtasks-toggle:focus-visible {
  border-radius: 6px;
  outline: 3px solid color-mix(in srgb, var(--tasks-primary, var(--app-primary)) 30%, transparent);
  outline-offset: 3px;
}

.task-subtask-preview > .completed-subtasks-toggle {
  margin-top: 0.05rem;
}

.task-subtask-editor__heading > .completed-subtasks-toggle {
  justify-content: flex-end;
}

.task-tag-picker {
  grid-column: 1 / -1;
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.task-tag-picker legend {
  margin-bottom: .5rem;
  color: var(--color-muted);
  font-size: .8rem;
  font-weight: var(--font-weight-strong);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.task-tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.task-tag-chip {
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-card);
  color: var(--color-ink);
  padding: .45rem .75rem;
  font: inherit;
  overflow-wrap: anywhere;
  max-width: 100%;
  min-height: 44px;
  cursor: pointer;
}
.task-tag-picker__selection { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.task-tag-chip { background: var(--color-teal-tint); }
.task-tag-picker__panel {
  box-sizing: border-box;
  width: min(34rem, calc(100% - 2rem));
  max-height: min(32rem, 65dvh);
  margin: auto;
  border: 1px solid var(--color-line);
  border-radius: 24px;
  padding: 2rem 2rem 2.5rem;
  background: var(--color-card);
  color: var(--color-ink);
  overflow: hidden;
}
.task-tag-picker__panel[open] { display: flex; flex-direction: column; }
.task-tag-picker__panel > :not(.bulk-tag-entry) { flex-shrink: 0; }
.task-tag-picker__panel::backdrop { background: rgb(0 0 0 / 20%); }
.task-tag-picker__header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.task-tag-picker__header h2 { margin: 0; }
.task-tag-picker__header .app-button { border: 0; background: transparent; color: var(--color-teal-dark); }
.task-tag-picker__handle { display: none; }
.task-tag-picker__create {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  min-height: 44px;
  padding: .5rem .65rem;
  border: 0;
  background: transparent;
  color: var(--color-teal-dark);
  font: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.task-tag-picker__create svg { width: 1.2rem; height: 1.2rem; flex-shrink: 0; }
.task-tag-picker__create:disabled { opacity: .55; }
.task-tag-picker__create:not(:disabled):hover { background: var(--color-teal-tint); }
.task-tag-picker__create span { min-width: 0; }

@media (max-width: 700px) {
  .task-tag-picker__panel { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 24px 24px 0 0; padding: 1rem 1.5rem max(2.5rem, env(safe-area-inset-bottom)); }
  .task-tag-picker__handle { display: block; width: 2.5rem; height: .25rem; border-radius: 999px; background: var(--color-line); margin: 0 auto 1.5rem; }
}
.task-tag-picker__options {
  display: grid;
  gap: .25rem;
  margin-top: 1.25rem;
  min-height: 0;
  flex: 1 1 auto;
  grid-auto-rows: minmax(min-content, auto);
  padding-right: .5rem;
  scrollbar-gutter: stable;
  overflow-y: auto;
}
.task-tag-picker__options label {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
  padding: .5rem 0;
  box-sizing: border-box;
  border-bottom: 1px solid var(--color-line);
  overflow-wrap: anywhere;
}
[data-tag-search] [hidden] {
  display: none !important;
}
[data-tag-search-input] {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--color-line);
  border-radius: 10px;
  padding: .5rem .75rem;
  background: var(--color-card);
  color: var(--color-ink);
  font: inherit;
}
.task-tag-picker [data-tag-status]:empty {
  display: none;
}

.task-tag-picker__options input[type="checkbox"] { width: 1.25rem; height: 1.25rem; flex-shrink: 0; accent-color: var(--color-teal-dark); }

.task-tag-picker__panel [data-tag-search-input] { min-height: 52px; padding: .75rem 1rem; }
.task-tag-picker__options label:last-child { border-bottom: 0; }

/* Chore labels share the row link; tag filtering preserves the status lens. */
.chore-row-tags { display: flex; flex-wrap: wrap; gap: .25rem .65rem; }
.chore-row-tag {
  display: inline-flex;
  align-items: baseline;
  gap: .3rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: .75rem;
  color: var(--app-primary-ink);
}
.chore-row-tag svg { width: .85rem; height: .85rem; flex: 0 0 auto; align-self: center; }

/* Tag choices expand in the list flow instead of covering tasks. */
body .page-shell .chore-tag-filter .chore-tag-filter__options {
  display: grid;
  box-sizing: border-box;
  width: calc(200% + .5rem);
  margin: .5rem 0 0;
  padding: .5rem;
  gap: .5rem;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-surface);
  min-width: 0;
}
.chore-tag-filter__toolbar { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.chore-tag-filter__toolbar [data-tag-filter-search] { flex: 1; width: 0; min-width: 0; min-height: 44px; padding: .45rem .6rem; font-size: 16px; }
.chore-tag-filter__choices {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: .4rem;
  border: 0; padding: 0; margin: 0; min-width: 0; min-height: 0;
  max-height: min(12rem, var(--chore-tag-menu-height, 35dvh));
  overflow-y: auto; overscroll-behavior: contain;
}
.chore-tag-filter__choice, .chore-tag-filter__all {
  box-sizing: border-box;
  display: inline-flex; align-items: center; gap: .35rem; max-width: 100%;
  min-height: 44px; padding: .4rem .65rem; border: 1px solid var(--app-line);
  border-radius: 999px; background: var(--app-surface); color: var(--app-muted);
  font: inherit; font-size: .9rem; text-decoration: none; cursor: pointer;
}
.chore-tag-filter__choice:has(:checked), .chore-tag-filter__all.is-selected {
  border-color: color-mix(in srgb, var(--app-primary) 24%, var(--app-line)); background: var(--app-primary-soft); color: var(--app-primary-ink);
}
.chore-tag-filter__choice:focus-within, .chore-tag-filter__all:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.chore-tag-filter__choice input {
  appearance: none; display: grid; place-items: center; flex: 0 0 auto;
  width: 1rem; height: 1rem; margin: 0; padding: 0; border: 0;
  border-radius: 0; background: transparent; color: inherit; cursor: pointer;
}
.chore-tag-filter__choice input::before { content: "#"; font: inherit; line-height: 1; }
.chore-tag-filter__choice input:checked::before { content: "✓"; }
.chore-tag-filter__choice input:focus { outline: none; }
.chore-tag-filter__choice span { overflow-wrap: anywhere; min-width: 0; }
.chore-tag-filter__choice[hidden], .chore-tag-filter__empty[hidden], .chore-tag-filter__error[hidden] { display: none; }
.chore-tag-filter__all { flex: 0 0 auto; }
.chore-tag-filter__all > svg { width: 1rem; height: 1rem; flex: 0 0 auto; }
.chore-tag-filter__empty, .chore-tag-filter__error { margin: 0; font-size: .85rem; color: var(--app-muted); }
.chore-tag-filter__error { color: var(--app-danger); }
.chore-tag-filter__options[aria-busy="true"] { opacity: .65; }

/* Native disclosures keep section counts visible and work without JavaScript. */
.page-shell--tasks details.task-section--shopping-tag { display: block; }
body .page-shell.page-shell--tasks .task-section.task-section--shopping-tag > summary.task-section__header {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: .75rem;
  padding: .35rem .75rem;
  min-height: 44px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-primary-soft);
  cursor: pointer;
  list-style: none;
}
.page-shell--tasks .task-section--shopping-tag > summary::before,
.task-section--shopping-tag > summary::-webkit-details-marker { display: none; }
.page-shell--tasks .task-section--shopping-tag .task-section__count {
  background: none; padding: 0; font-size: .625rem; font-weight: var(--font-weight-body);
}
.task-section--shopping-tag .task-section__chevron { width: 1rem; height: 1rem; transform: rotate(-90deg); }
.task-section--shopping-tag[open] .task-section__chevron { transform: none; }
.task-section--shopping-tag > .task-list { margin-top: .65rem; }
.task-section--shopping-tag > summary:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.shopping-tag-add {
  display: grid;
  place-items: center;
  position: relative;
  width: 2.3rem;
  height: 2.3rem;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  background: var(--app-surface);
  color: var(--app-primary-ink);
  font-size: 1.22rem;
  line-height: 1;
  text-decoration: none;
}
.shopping-tag-add:hover { background: var(--app-primary-soft); }
.shopping-tag-add:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }
/* Equal visible gaps around the leading emoji; desktop emoji sizing is retained. */
.page-shell--tasks:not(.is-creating-task):not(.is-editing-task) .personal-task-row,
.page-shell--family .personal-task-row {
  grid-template-columns: 1.5rem minmax(0, 1fr);
  column-gap: 0.375rem;
}
@media (max-width: 760px) {
  .work-title-copy:has(.work-title__content) {
    grid-template-columns: 0.95rem minmax(0, 1fr);
  }
  .work-title__emoji { font-size: 0.95rem; }
.personal-task-row > :is(.task-row__url, .task-subtask-preview) {
    margin-inline-start: 1.325rem;
  }
}

@media (max-width: 760px) {
  .page-shell--tasks:not(.is-creating-task):not(.is-editing-task) .personal-task-row {
    grid-template-columns: 1.7rem minmax(0, 1fr);
  }
}
.tasks-list-titlebar__add { white-space: nowrap; }

/* The first title line follows the completion control, regardless of the
   height of the trailing status, notes, or nested work. */
body .page-shell :is(.daily-task-row, .daily-calendar-row, .personal-task-row) {
  --work-control-size: 1.5rem;
  align-items: start;
}
body .page-shell :is(.daily-task-row__main, .daily-calendar-row__main, .calendar-event-row__main, .personal-task-row__main) {
  align-items: start;
}
body .page-shell :is(.daily-task-toggle, .personal-task-toggle) {
  margin-block: 0;
}
body .page-shell .daily-calendar-row::before,
body .page-shell .calendar-event-row__main::before {
  align-self: start;
}
body .page-shell :is(.daily-task-row, .daily-calendar-row, .personal-task-row) :is(.task-row__title, .work-title__emoji),
body .page-shell .calendar-event-row__copy strong {
  line-height: var(--work-control-size, 1.5rem);
}
@media (max-width: 760px) {
  body .page-shell--tasks .personal-task-row { --work-control-size: 1.7rem; }
}

.bulk-tag-hint { margin: 0 0 1rem; color: var(--color-muted); }
.bulk-tag-apply { margin-top: 1rem; width: 100%; min-height: 44px; }

.tag-entry-input { display: flex; align-items: center; margin-top: .5rem; }
.tag-entry-hint { margin: .35rem 0 0; color: var(--color-muted); font-size: .78rem; }
.tag-entry-suggestions { margin-top: .4rem; border: 1px solid var(--color-line); border-radius: 12px; overflow: hidden; }
.tag-entry-suggestions .task-tag-picker__options { display: flex; flex-wrap: wrap; gap: .3rem; max-height: 11rem; margin: 0; padding: .35rem; }
.tag-entry-suggestions .task-tag-picker__options label { gap: .4rem; min-height: 44px; padding: .4rem .6rem; border: 0; border-radius: 8px; font-size: .88rem; cursor: pointer; }
.tag-entry-suggestions .task-tag-picker__options label:has(:checked) { color: var(--color-teal-dark); background: var(--color-teal-tint); }
.tag-entry-suggestions .task-tag-picker__options label:focus-within { outline: 2px solid var(--color-teal-dark); outline-offset: -2px; }
.bulk-tag-entry { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: .5rem; }
.task-tag-picker__panel .bulk-tag-apply { flex-shrink: 0; }

.task-tag-picker__panel .task-tag-picker__header { margin-bottom: .5rem; }
.task-tag-picker__panel .bulk-tag-hint { margin-block: .25rem .5rem; }
@media (max-width: 700px) {
  .task-tag-picker__panel { padding: .75rem 1rem max(.75rem, env(safe-area-inset-bottom)); }
  .task-tag-picker__panel .task-tag-picker__handle { margin-bottom: .5rem; }
}

.bulk-tag-entry .task-tag-picker legend { display: none; }

/* One tag entry line: selected hashtags and the next typed tag share the field. */
.tag-entry-input { flex-wrap: wrap; gap: .1rem .35rem; border: 1px solid var(--color-line); border-radius: 12px; padding: .15rem .5rem; background: var(--color-card); }
.tag-entry-input:focus-within { outline: 2px solid var(--color-teal-dark); outline-offset: 1px; }
.tag-entry-input .task-tag-chips { display: contents; }
.tag-entry-input .task-tag-chip { min-height: 44px; padding: .15rem .2rem; border: 0; border-radius: 4px; background: transparent; color: var(--color-teal-dark); font-size: 1rem; }
.tag-entry-input .task-tag-chip:hover, .tag-entry-input .task-tag-chip:focus-visible { background: var(--color-teal-tint); }
.tag-entry-input [data-tag-search-input] { font-size: 16px; width: 0; flex: 1 1 8rem; min-width: min(8rem, 100%); border: 0; background: transparent; box-shadow: none; outline: none; padding: .4rem .2rem; }
.shopping-tag-add::after { content: ""; position: absolute; inset: min(0px, calc((2.3rem - 44px) / 2)); }
.tasks-extra-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: .5rem; width: 16rem; min-width: 0; }
.tasks-extra-filters > * { min-width: 0; }
.tasks-list-titlebar__controls:has(.chore-tag-filter[open]) :is(.list-titlebar-utility-buttons, .tasks-list-titlebar__add) { align-self: flex-start; }
.task-date-filter__options { min-width: 11rem; max-height: var(--chore-tag-menu-height, 60dvh); overflow: auto; }
.task-date-filter__options a { display: flex; justify-content: space-between; gap: .75rem; padding: .7rem; min-height: 44px; align-items: center; color: var(--app-ink); text-decoration: none; }
.task-date-filter__options a[aria-current] { color: var(--app-primary-ink); background: var(--app-primary-soft); }
@media (max-width: 760px) {
  .tasks-extra-filters { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tasks-extra-filters .list-filter__menu { width: 100%; }
  .tasks-extra-filters .list-filter__menu-trigger { width: 100%; justify-content: space-between; }
}
