/* ==================================================================================================
   Schedule — project Calendar + Timeline (Gantt). Owner: schedule agent.
   Markup: templates/projects/{calendar,timeline}.html + partials/{calendar,timeline}_*.html
   Behaviour: static/js/schedule.js. Tokens only (var(--…)); everything is scoped under .schedule,
   .sched-* or .tl-* / .cal-* roots. Custom properties of the timeline are prefixed --tl-* (and
   --tl-day is registered with @property so zoom changes animate).

   .schedule            page root (#schedule; children swapped with morph:innerHTML)
   .sched-toolbar       nav + title (lead) and tools (My tasks, Filter, view switch)
   .sched-seg           morph-safe segmented control (server renders the active item)
   .cal / .cal-day …    month + week grid, chips (.cal-chip), "+N more" popover (.cal-more)
   .cal-tray            "Unscheduled" strip above the grid (≥ 768px) — a drop zone too
   .cal-agenda / .cal-row   phone agenda (< 768px)
   .tl / .tl-*          timeline: sticky header + task column, lanes, bars, milestones, ghosts
   .sched-pop           date popover · .tl-tip  hover card for bars and chips (created by JS)
   ================================================================================================== */

/* -- Root & period header ------------------------------------------------------------------------
   The filters live in the shared task toolbar (header row 2, projects/partials/task_toolbar.html).
   Inside #schedule a slim header row holds what belongs to the period: ‹ Today › + the period title
   (lead) and the range / zoom switch + the Unscheduled toggle (tools) — toolbar-sized controls. */
.schedule {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  transition: opacity var(--dur-2) ease;
}
/* Filters just changed: dim after a beat until the new fragment lands (like the board / list). */
.schedule.is-filtering {
  opacity: 0.6;
  transition-delay: 120ms;
}

.sched-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  min-width: 0;
  min-height: var(--control-h-sm);
}
.sched-toolbar__lead,
.sched-toolbar__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.sched-toolbar__lead {
  flex: 1 1 auto;
  gap: var(--space-3);
}
/* r4 · 12.9: period title like macOS Calendar — "October" 600 + a muted "2026" (22 px). */
.sched-title {
  display: flex;
  align-items: baseline;
  gap: 0.28em;
  min-width: 0;
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-title-2);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-snug);
  line-height: 1.15;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.sched-title__main::first-letter {
  text-transform: uppercase;
}
.sched-title__year {
  color: var(--text-2);
  font-weight: var(--fw-regular);
}

/* r4 · 12.9: ‹ Today › — one glass capsule (macOS toolbar button group, 4.3 .glass-capsule). */
.sched-nav {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0;
  height: calc(var(--control-h-sm) + 4px);
  padding: 2px;
  border: 0.5px solid var(--glass-border);
  border-radius: var(--radius-full);
  background: var(--glass-sheen), var(--mat-thin);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow: var(--glass-rim), var(--shadow-sm);
}
.sched-nav .btn {
  height: var(--control-h-sm);
  min-height: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  box-shadow: none;
  color: var(--text);
  transition:
    background-color var(--dur-1) ease,
    transform var(--dur-snappy) var(--spring-snappy);
}
.sched-nav .btn--icon {
  width: var(--control-h-sm);
}
.sched-nav .btn:hover {
  background: var(--fill-1);
}
.sched-nav .btn:active {
  background: var(--fill-2);
  transform: scale(0.94);
}
.sched-nav .btn[aria-disabled="true"] {
  opacity: 0.35;
  pointer-events: none;
}
.sched-nav__today {
  position: relative;
  padding-inline: 12px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
/* Hairlines between the three segments of the capsule */
.sched-nav__today::before,
.sched-nav__today::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 0.5px;
  background: var(--line-strong);
  pointer-events: none;
}
.sched-nav__today::before {
  left: 0;
}
.sched-nav__today::after {
  right: 0;
}
.sched-nav__today.is-current {
  color: var(--accent-ink);
}

/* r4 · 12.9: "Unscheduled 3" — a capsule button that opens the floating tray (popover). */
.sched-toggle {
  gap: 6px;
  height: calc(var(--control-h-sm) + 4px);
  padding-inline: 12px 6px;
  font-weight: var(--fw-medium);
}
.sched-toggle[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.sched-toggle__count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--fill-2);
  color: var(--text-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.sched-toggle[aria-expanded="true"] .sched-toggle__count {
  background: var(--accent);
  color: var(--text-on-accent);
}

/* r4 · 9.6: range / zoom switch — the iOS segmented capsule. Rendered by the server (no JS thumb →
   survives morph swaps): the selected item carries the thumb itself and pops in with a spring. */
.sched-seg {
  display: inline-flex;
  flex-shrink: 0;
  gap: 0;
  height: calc(var(--control-h-sm) + 4px);
  padding: 2px;
  border-radius: var(--radius-full);
  background: var(--segmented-bg, var(--fill-2));
}
.sched-seg__item {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 100%;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
  white-space: nowrap;
  cursor: default;
  transition: color var(--dur-2) ease;
}
.sched-seg__item + .sched-seg__item::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 1px;
  background: var(--line);
  transition: opacity var(--dur-1) ease;
}
.sched-seg__item:is([aria-current="page"], [aria-pressed="true"])::before,
.sched-seg__item:is([aria-current="page"], [aria-pressed="true"]) + .sched-seg__item::before {
  opacity: 0;
}
.sched-seg__item:hover {
  color: var(--text);
}
.sched-seg__item:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 1px;
}
.sched-seg__item[aria-current="page"],
.sched-seg__item[aria-pressed="true"] {
  background: var(--segmented-thumb);
  box-shadow: var(--segmented-thumb-shadow);
  color: var(--text);
  font-weight: var(--fw-semibold);
}
@media (prefers-reduced-motion: no-preference) {
  .sched-seg__item[aria-current="page"],
  .sched-seg__item[aria-pressed="true"] {
    animation: sched-seg-in var(--dur-snappy) var(--spring-snappy);
  }
  @keyframes sched-seg-in {
    from {
      transform: scale(0.9);
      opacity: 0.6;
    }
  }
}

/* A project without tasks: the timeline shows the one empty state instead of the chart; the
   calendar keeps its grid (a day is a place to add a task) under a slim card. */
.empty-project--slim {
  justify-content: flex-start;
  padding: 0;
}
.empty-project--slim > .empty-state {
  width: 100%;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--card-ring);
}
.tl-empty--project {
  padding-block: var(--space-6);
}

/* -- Calendar: layout ------------------------------------------------------------------------------ */
/* r4 · 12.9 (macOS Calendar): the grid is one white card on the grouped background; the Unscheduled
   tray floats over its top-right corner like a popover from its toolbar button (≥ 768px). */
.cal-layout {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}
.cal-main {
  min-width: 0;
}
.cal {
  --cal-line: light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.08));
  display: none; /* phones use the agenda */
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow:
    0 0 0 0.5px var(--card-ring),
    var(--shadow-sm),
    inset 0 0.5px 0 var(--card-highlight);
}
.cal-tray,
.cal-tray-toggle {
  display: none;
}
@media (min-width: 768px) {
  .cal {
    display: flex;
    flex-direction: column;
  }
  .cal-tray-toggle {
    display: inline-flex;
  }
  .cal-layout.is-tray-open .cal-tray {
    display: flex;
  }
}

/* Month grid */
.cal__weekdays,
.cal__week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.cal__weekdays {
  box-shadow: inset 0 -0.5px 0 var(--line);
}
/* Weekday names: 11px semibold, right-aligned over the date numbers (macOS). */
.cal__weekday {
  padding: 8px 12px 6px;
  color: var(--text-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  text-align: right;
}
.cal__weekday abbr {
  text-decoration: none;
  cursor: default;
}
.cal__weekday abbr::first-letter {
  text-transform: uppercase;
}
.cal__body {
  display: grid;
  grid-template-rows: repeat(var(--cal-weeks, 5), minmax(112px, 1fr));
  min-height: max(560px, var(--sched-fill, 0px));
}
.cal__week + .cal__week {
  box-shadow: inset 0 0.5px 0 var(--cal-line);
}

.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 4px 5px 6px;
  transition: background-color var(--dur-1) ease;
}
.cal-day + .cal-day,
.cal-wday + .cal-wday {
  box-shadow: inset 0.5px 0 0 var(--cal-line);
}
/* Weekends: a whisper of fill — lighter than --fill-1. */
.cal-day.is-weekend,
.cal-wday.is-weekend {
  background: color-mix(in srgb, var(--fill-1) 50%, transparent);
}
@media (hover: hover) {
  .cal-day:hover {
    background: color-mix(in srgb, var(--fill-1) 75%, transparent);
  }
}
.cal-day.is-drop-target,
.cal-wday.is-drop-target {
  background: var(--accent-softer);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
}
.cal-day.is-drop-target .cal-day__num,
.cal-wday.is-drop-target .cal-wday__num {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
/* Date number in the top-right corner; "+" sits at the left of the same row. */
.cal-day__head {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 24px;
  margin-bottom: 2px;
}
.cal-day__num {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition:
    background-color var(--dur-1) ease,
    color var(--dur-1) ease;
}
.cal-day.is-outside .cal-day__num {
  color: var(--text-3);
  font-weight: var(--fw-regular);
}
.cal-day.is-today .cal-day__num,
.cal-wday.is-today .cal-wday__num {
  padding: 0;
  background: var(--accent);
  color: var(--text-on-accent);
  font-weight: var(--fw-semibold);
}
.cal-day.is-today .cal-day__num {
  width: 24px;
}
.cal-day__add {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-2);
  opacity: 0;
  transform: scale(0.8);
  transition:
    opacity var(--dur-1) ease,
    transform var(--dur-snappy) var(--spring-snappy),
    background-color var(--dur-1) ease;
}
.cal-day__add:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.cal-day__add:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 1px;
}
.cal-day__add:focus-visible,
.cal-day:hover .cal-day__add,
.cal-wday:hover .cal-day__add,
.cal-day:focus-within .cal-day__add,
.cal-wday:focus-within .cal-day__add {
  opacity: 1;
  transform: none;
}
@media (hover: none) {
  .cal-day__add {
    opacity: 0.7;
    transform: none;
  }
}
.cal-day__list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  min-height: 20px;
}
.schedule[data-schedule="calendar"] .cal-day[data-date] {
  cursor: default;
}
.cal-day__more {
  align-self: flex-start;
  height: 20px;
  margin: 1px 0 0;
  padding: 0 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background-color var(--dur-1) ease;
}
.cal-day__more:hover,
.cal-day__more[aria-expanded="true"] {
  background: var(--fill-2);
  color: var(--text);
}
.cal-day__more:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 1px;
}

/* Chips */
/* r4 · 12.9 — Calendar events: a tone-softer pill with a 3px tone bar on the left and tone-ink text
   (tone = status column color). Overdue switches the tone to --danger; done is struck through and
   muted. 20px tall, radius 5. */
.cal-chip {
  --chip-bg: var(--tone-softer);
  --chip-bg-hover: var(--tone-soft);
  --chip-bar: var(--tone);
  position: relative;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
  min-width: 0;
  height: 20px;
  padding: 0 5px 0 8px;
  border-radius: 5px;
  background: var(--chip-bg);
  box-shadow: inset 3px 0 0 var(--chip-bar);
  color: var(--tone-ink);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  text-decoration: none;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition:
    background-color var(--dur-1) ease,
    box-shadow var(--dur-2) var(--ease-out),
    opacity var(--dur-2) ease,
    transform var(--dur-snappy) var(--spring-snappy);
}
.cal-chip[data-movable] {
  cursor: grab;
}
.cal-chip:hover {
  background: var(--chip-bg-hover);
}
.cal-chip:focus-visible {
  outline: none;
  box-shadow:
    inset 3px 0 0 var(--chip-bar),
    0 0 0 2px var(--surface),
    0 0 0 4px var(--focus-outline);
}
.cal-chip.is-current {
  --chip-bg: var(--tone-soft);
  box-shadow:
    inset 3px 0 0 var(--chip-bar),
    0 0 0 1.5px var(--accent);
}
/* The bar already carries the status color: no dot in compact chips. */
.cal-chip__dot {
  display: none;
}
.cal-chip__icon {
  flex-shrink: 0;
}
.cal-chip__icon--done {
  color: var(--success);
}
.cal-chip__icon--milestone {
  color: var(--accent);
}
.cal-chip__icon--milestone,
.cal-row__icon.cal-chip__icon--milestone {
  fill: currentColor;
}
.cal-chip__title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-chip.is-milestone .cal-chip__title {
  font-weight: var(--fw-semibold);
}
.cal-chip .priority {
  flex-shrink: 0;
}
/* Overdue: red bar, tint and text (the status dot of week cards keeps the column's tone). */
.cal-chip.is-overdue {
  --chip-bg: color-mix(in srgb, var(--danger) 9%, transparent);
  --chip-bg-hover: color-mix(in srgb, var(--danger) 15%, transparent);
  --chip-bar: var(--danger);
  color: var(--danger-ink);
}
.cal-chip.is-done {
  --chip-bg: var(--fill-1);
  --chip-bg-hover: var(--fill-2);
  --chip-bar: color-mix(in srgb, var(--tone) 40%, transparent);
  color: var(--text-3);
}
.cal-chip.is-done .cal-chip__title {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, currentColor 60%, transparent);
}
.cal-chip.is-saving {
  opacity: 0.6;
}
@media (prefers-reduced-motion: no-preference) {
  .cal-chip {
    animation: cal-chip-in var(--dur-3) var(--ease-out) backwards;
  }
  @keyframes cal-chip-in {
    from {
      opacity: 0;
      transform: translateY(3px);
    }
  }
  .cal-chip.is-landed {
    animation: cal-land var(--dur-bouncy) var(--spring-bouncy);
  }
  @keyframes cal-land {
    from {
      transform: scale(0.9);
    }
  }
  .cal-chip.is-shake {
    animation: cal-shake 360ms var(--ease-out);
  }
  @keyframes cal-shake {
    20%,
    60% {
      transform: translateX(-3px);
    }
    40%,
    80% {
      transform: translateX(3px);
    }
  }
}
/* Week-view events: the same language, roomier (title on up to three lines + meta row). */
.cal-chip--card {
  flex-wrap: wrap;
  align-items: flex-start;
  height: auto;
  padding: 6px 8px 6px 11px;
  border-radius: var(--radius-sm);
  row-gap: 5px;
}
.cal-chip--card:hover {
  background: var(--chip-bg-hover);
}
.cal-chip--card .cal-chip__icon {
  margin-top: 1px;
}
.cal-chip--card .cal-chip__title {
  flex-basis: 0;
  display: -webkit-box;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow-wrap: break-word;
}
.cal-chip__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 7px;
  width: 100%;
  min-height: 20px;
  color: var(--text-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-regular);
}
.cal-chip.is-done .cal-chip__meta {
  color: var(--text-3);
}
.cal-chip__status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-chip__status::before {
  content: "";
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--tone);
}
.cal-chip__avatar {
  display: inline-flex;
  margin-left: auto;
}
/* Drag & drop (SortableJS fallback mode). r4 · 7.9: Sortable writes an inline translate3d on the
   clone, so the lift uses the individual rotate / scale properties. */
.cal-chip.sortable-ghost {
  --chip-bg: transparent;
  box-shadow: none;
  outline: 1.5px dashed color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: -1.5px;
  opacity: 1;
  animation: none;
}
.cal-chip.sortable-ghost > * {
  visibility: hidden;
}
.cal-chip.sortable-fallback,
.cal-chip.sortable-drag {
  z-index: var(--z-overlay);
  --chip-bg: light-dark(
    color-mix(in srgb, var(--tone) 12%, var(--surface)),
    color-mix(in srgb, var(--tone) 24%, var(--surface))
  );
  box-shadow:
    inset 3px 0 0 var(--chip-bar),
    0 0 0 0.5px var(--card-ring),
    var(--shadow-lift) !important;
  rotate: -1.5deg;
  scale: 1.04;
  transition: none !important;
  cursor: grabbing;
  animation: none;
  will-change: transform;
}
.schedule.is-dragging,
.schedule.is-dragging * {
  cursor: grabbing !important;
}

/* "+N more" popover */
.cal-more {
  width: min(320px, calc(100vw - 16px));
  padding: 8px;
}
.cal-more__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 8px 4px;
}
.cal-more__day {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--fill-1);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
}
.cal-more__day.is-today {
  background: var(--accent);
  color: var(--text-on-accent);
}
.cal-more__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
}
.cal-more__title::first-letter {
  text-transform: uppercase;
}
.cal-more__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(360px, 60vh);
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}
.cal-more__item {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.cal-more__item .cal-chip {
  flex: 1 1 auto;
  height: 30px;
  font-size: var(--fs-sm);
  animation: none;
}
.cal-more__move {
  flex-shrink: 0;
  color: var(--text-2);
}
/* Placeholder rows while the day's list loads (it's fetched when the popover opens). */
.cal-more__item--skeleton .skeleton {
  flex: 1 1 auto;
  height: 30px;
  border-radius: var(--radius-sm);
}
.cal-more__item--empty {
  padding: 6px;
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.cal-more__add {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 6px;
  padding: 7px 8px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: transparent;
  color: var(--accent-ink);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-align: left;
}
.cal-more__add:hover {
  background: var(--accent-softer);
}
/* "Show N more" under a long week column / agenda day (morphs the page to ?show=…). */
.cal-expand {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  margin: 2px 4px 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--accent-ink);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
}
.cal-expand:hover {
  background: var(--accent-softer);
}
.cal-expand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Week view — macOS Calendar week header: "Mon" small caps over a large date; today in an accent
   circle. */
.cal--week .cal__week--days {
  min-height: max(520px, var(--sched-fill, 0px));
}
.cal-wday {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 0 5px 12px;
  transition: background-color var(--dur-1) ease;
}
.cal-wday__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 6px;
  margin: 0 -5px 4px;
  padding: 10px 10px 8px;
  box-shadow: inset 0 -0.5px 0 var(--line);
}
.cal-wday__name {
  grid-column: 1 / span 2;
  color: var(--text-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
}
.cal-wday__name::first-letter {
  text-transform: uppercase;
}
.cal-wday.is-today .cal-wday__name {
  color: var(--accent-ink);
}
.cal-wday__num {
  grid-row: 2;
  grid-column: 1;
  justify-self: start;
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  margin: 2px 0 0 -6px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: var(--fs-title-3);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-snug);
}
.cal-wday.is-today .cal-wday__num {
  width: 32px;
  padding: 0;
}
.cal-wday__count {
  grid-row: 2;
  grid-column: 2;
  justify-self: start;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--fill-1);
  color: var(--text-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.cal-wday .cal-day__add {
  grid-row: 1 / span 2;
  grid-column: 3;
}
.cal-wday__list {
  gap: 4px;
  min-height: 80px;
}
/* Narrow calendars (tablets, laptops with the sidebar open): seven columns would break long
   Kyrgyz words mid-word, so the week becomes seven rows — the day on the left, its cards in a
   wrapping row on the right. Drag & drop and "click empty space to add" work the same. */
.cal-main {
  container: cal-main / inline-size;
}
@container cal-main (max-width: 1150px) {
  .cal-wday {
    padding-inline: 4px;
  }
  .cal-chip--card .cal-chip__title {
    font-size: var(--fs-xs);
    line-height: 1.3;
  }
}
@container cal-main (max-width: 900px) {
  .cal--week .cal__week--days {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .cal-wday {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 4px 12px;
    padding: 10px 12px 10px 14px;
  }
  .cal-wday + .cal-wday {
    box-shadow: inset 0 0.5px 0 var(--cal-line);
  }
  .cal-wday__head {
    grid-row: 1 / span 2;
    grid-template-columns: auto 1fr auto;
    align-self: start;
    margin: 0;
    padding: 2px 0 0;
    box-shadow: none;
  }
  .cal-wday__list {
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    min-height: 48px;
  }
  .cal-wday__list .cal-chip--card {
    flex: 0 1 260px;
    min-width: 0;
  }
  .cal-wday .cal-expand {
    grid-column: 2;
  }
}

/* Unscheduled tray (≥ 768px) — r4 · 12.9: a glass popover that floats from the "Unscheduled"
   button over the grid's top-right corner. It is not a top-layer popover: SortableJS drags chips
   out of it onto days (it fades and lets the pointer through meanwhile) and back into it. The open
   state survives refreshes (cookie sched_tray). */
.cal-tray {
  position: absolute;
  top: -2px;
  right: 0;
  z-index: var(--z-raised);
  flex-direction: column;
  gap: 8px;
  width: min(360px, 100%);
  max-height: min(440px, max(240px, calc(var(--sched-fill, 70vh) - 16px)));
  min-width: 0;
  padding: 12px;
  border: 0.5px solid var(--glass-border);
  border-radius: var(--radius-menu);
  background: var(--glass-sheen), var(--mat-thick);
  -webkit-backdrop-filter: var(--mat-filter-strong);
  backdrop-filter: var(--mat-filter-strong);
  box-shadow: var(--glass-rim), var(--shadow-lg);
  transform-origin: calc(100% - 48px) 0;
  transition: opacity var(--dur-2) ease;
}
@media (prefers-reduced-motion: no-preference) {
  .cal-layout.is-tray-open .cal-tray {
    animation: cal-tray-in var(--dur-smooth) var(--spring-smooth);
  }
  @keyframes cal-tray-in {
    from {
      opacity: 0;
      transform: translateY(-6px) scale(0.94);
    }
  }
}
/* Dragging a chip out of the tray: reveal the days underneath. */
.schedule.is-dragging-from-tray .cal-tray {
  opacity: 0.12;
  pointer-events: none;
}
.cal-tray__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 8px;
  min-width: 0;
  padding: 0 0 0 4px;
}
.cal-tray__title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
}
.cal-tray__title .icon {
  flex-shrink: 0;
  color: var(--accent);
}
.cal-tray__count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--fill-2);
  color: var(--text-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.cal-tray__hint {
  grid-row: 2;
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-xs);
  line-height: 1.35;
}
.cal-tray__close {
  grid-row: 1;
  grid-column: 2;
  margin: -4px -4px -4px 0;
  border-radius: var(--radius-full);
  color: var(--text-2);
}
.cal-tray__list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 56px;
  padding: 5px;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: calc(var(--radius-menu) - 6px);
  background: light-dark(rgb(255 255 255 / 0.55), rgb(0 0 0 / 0.18));
  box-shadow: inset 0 0 0 0.5px var(--line);
  transition:
    background-color var(--dur-2) ease,
    box-shadow var(--dur-2) ease;
}
.cal-tray__list.is-drop-target {
  background: var(--accent-softer);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent);
}
.cal-tray__list .cal-chip {
  flex: 0 0 auto;
  height: 28px;
  padding-inline: 10px 8px;
  border-radius: var(--radius-xs);
  font-size: var(--fs-sm);
}
.cal-tray__empty,
.cal-tray__more {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px;
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.cal-tray__empty .icon {
  color: var(--success);
}

/* -- Phone agenda ---------------------------------------------------------------------------------- */
/* r4 · 12.9 (iOS Calendar list): each day is an inset grouped section — a sticky day header on the
   grouped background ("Today  Thursday, 29 October" in accent for today) over a white rounded group
   of rows with inset separators. --sched-top (schedule.js) = the sticky toolbar's height. */
.cal-agenda {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
@media (min-width: 768px) {
  .cal-agenda {
    display: none;
  }
}
.cal-agenda__day {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cal-agenda__date {
  position: sticky;
  top: var(--sched-top, 0px);
  z-index: 2;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 8px;
  min-height: 44px;
  margin: 0 calc(-1 * var(--space-1));
  padding: 12px calc(48px + var(--space-1)) 6px calc(16px + var(--space-1));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  font-family: var(--font-sans);
  font-size: var(--type-body);
  font-weight: var(--fw-regular);
  letter-spacing: 0;
}
/* The big date tile of r3 is gone; the day name leads (the number stays for the tray's icon). */
.cal-agenda__num {
  display: none;
}
.cal-agenda__num--icon {
  display: inline-flex;
  align-self: center;
  color: var(--accent);
}
.cal-agenda__name {
  display: contents;
}
.cal-agenda__wd {
  font-size: var(--type-headline);
  font-weight: var(--fw-semibold);
}
.cal-agenda__wd::first-letter,
.cal-agenda__month::first-letter {
  text-transform: uppercase;
}
.cal-agenda__month {
  color: var(--text-2);
  font-size: var(--type-subhead);
}
.cal-agenda__day.is-today .cal-agenda__wd,
.cal-agenda__day.is-today .cal-agenda__month {
  color: var(--accent-ink);
}
.cal-agenda__day.is-past:not(.is-today) .cal-agenda__wd {
  color: var(--text-2);
}
/* "+" rides along with the sticky day header (same top; pulled up over the header row). */
.cal-agenda__add {
  position: sticky;
  top: var(--sched-top, 0px);
  z-index: 3;
  align-self: flex-end;
  width: var(--hit-min);
  height: var(--hit-min);
  margin: -50px 2px 0 0;
  border-radius: var(--radius-full);
  color: var(--accent);
}
.cal-agenda__list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow:
    0 0 0 0.5px var(--card-ring),
    var(--shadow-xs),
    inset 0 0.5px 0 var(--card-highlight);
  list-style: none;
}
.cal-agenda__empty {
  padding: 14px 16px;
  color: var(--text-3);
  font-size: var(--type-subhead);
}
.cal-agenda__none {
  padding: var(--space-8) 0;
}
.cal-agenda__day > .cal-expand {
  margin: 0 8px;
}
/* Earlier days of the current period, folded into one grouped row. */
.cal-agenda__earlier {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.cal-agenda__earlier-sum {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--row-h-list);
  padding: 0 16px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow:
    0 0 0 0.5px var(--card-ring),
    var(--shadow-xs);
  color: var(--text);
  font-size: var(--type-body);
  font-weight: var(--fw-regular);
  list-style: none;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-1) ease;
}
.cal-agenda__earlier-sum:active {
  background: var(--fill-1);
}
.cal-agenda__earlier-sum::-webkit-details-marker {
  display: none;
}
.cal-agenda__earlier-sum:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
}
.cal-agenda__earlier-icon {
  flex-shrink: 0;
  color: var(--text-2);
}
.cal-agenda__earlier-text {
  flex: 1 1 auto;
  min-width: 0;
}
.cal-agenda__earlier-count {
  color: var(--text-2);
  font-size: var(--type-body);
  font-variant-numeric: tabular-nums;
}
.cal-agenda__earlier-chev {
  flex-shrink: 0;
  color: var(--text-3);
  transition: transform var(--dur-snappy) var(--spring-snappy);
}
.cal-agenda__earlier[open] .cal-agenda__earlier-chev {
  transform: rotate(180deg);
}
.cal-agenda__earlier-days {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.cal-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 9px 4px 9px 12px;
  transition: background-color var(--dur-1) ease;
  -webkit-tap-highlight-color: transparent;
}
/* Inset separators (iOS): they start after the color bar. */
.cal-row + .cal-row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 26px;
  height: 0.5px;
  background: var(--line);
}
.cal-row:active {
  background: var(--fill-1);
}
.cal-row.is-current {
  background: var(--accent-softer);
}
.cal-row__bar {
  align-self: stretch;
  width: 4px;
  flex-shrink: 0;
  margin: 1px 0;
  border-radius: var(--radius-full);
  background: var(--tone);
}
.cal-row.is-overdue .cal-row__bar {
  background: var(--danger);
}
.cal-row__main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 1px 0;
  color: inherit;
  text-decoration: none;
}
.cal-row__main::after {
  content: "";
  position: absolute;
  inset: 0;
}
.cal-row__main:focus-visible {
  outline: none;
}
.cal-row:has(.cal-row__main:focus-visible) {
  box-shadow: inset 0 0 0 2px var(--focus-outline);
}
.cal-row .avatar,
.cal-row__move {
  position: relative;
  z-index: 1;
}
.cal-row__title {
  display: -webkit-box;
  overflow: hidden;
  font-size: var(--type-body);
  font-weight: var(--fw-regular);
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: break-word;
}
.cal-row__icon {
  margin-right: 5px;
  vertical-align: -2px;
}
.cal-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 9px;
  color: var(--text-2);
  font-size: var(--type-footnote);
}
.cal-row__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cal-row__status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tone);
}
.cal-row__overdue,
.cal-row__dates {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}
.cal-row__overdue {
  color: var(--danger-ink);
  font-weight: var(--fw-medium);
}
.cal-row__move {
  width: var(--hit-min);
  height: var(--hit-min);
  border-radius: var(--radius-full);
  color: var(--accent);
}
.cal-row.is-done .cal-row__title {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, currentColor 50%, transparent);
}
.cal-row.is-done .cal-row__bar {
  opacity: 0.4;
}

/* -- Timeline -------------------------------------------------------------------------------------- */
/* --tl-day is registered so zoom changes animate every bar, header cell and grid line together. */
@property --tl-day {
  syntax: "<length>";
  inherits: true;
  initial-value: 16px;
}
.tl {
  --tl-day: 16px;
  --tl-left-w: 232px;
  --tl-row-h: 40px;
  --tl-bar-h: 22px;
  --tl-head-h: 58px;
  --tl-head-top-h: 26px;
  --tl-ms: 14px;
  --tl-bar-radius: 7px;
  --tl-now: var(--c-red);
  --tl-grid-line: color-mix(in srgb, var(--line) 60%, transparent);
  --tl-row-line: color-mix(in srgb, var(--line) 50%, transparent);
  --tl-weekend-fill: var(--fill-1);
  /* Opaque (sticky cells sit on top of the lanes): mixed from opaque surface tokens. */
  --tl-band: light-dark(
    color-mix(in srgb, var(--surface-sunken) 45%, var(--surface)),
    color-mix(in srgb, var(--surface-2) 80%, var(--surface))
  );
  --tl-hover: light-dark(
    color-mix(in srgb, var(--surface-sunken) 32%, var(--surface)),
    color-mix(in srgb, var(--surface-2) 60%, var(--surface))
  );
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow:
    0 0 0 0.5px var(--card-ring),
    var(--shadow-sm),
    inset 0 0.5px 0 var(--card-highlight);
}
.schedule[data-zoom="day"] .tl {
  --tl-day: 32px;
}
.schedule[data-zoom="month"] .tl {
  --tl-day: 4px;
}
@media (max-width: 767px) {
  .schedule[data-zoom="auto"] .tl {
    --tl-day: 4px;
  }
}
/* r4 · 12.10: a 280px task column on desktop. */
@media (min-width: 1024px) {
  .tl {
    --tl-left-w: 280px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .tl {
    transition: --tl-day var(--dur-3) var(--ease-out);
  }
}
.tl-scroll {
  position: relative;
  max-height: max(360px, var(--sched-fill, calc(100dvh - 240px)));
  overflow: auto;
  overscroll-behavior: contain;
  outline: none;
  scrollbar-gutter: stable;
  /* Focus / scrollIntoView keep bars out from under the sticky task column and date header. */
  scroll-padding: var(--tl-head-h) 0 0 calc(var(--tl-left-w) + 8px);
}
.tl-scroll:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.tl-canvas {
  position: relative;
  width: calc(var(--tl-left-w) + var(--tl-days) * var(--tl-day));
  min-width: 100%;
  overflow-x: clip; /* labels outside the last bars never widen the scroll area */
}

/* Header: two tiers (months · days / weeks / months) + the "today" pill.
   r4 · 12.10: a sticky glass strip — rows scroll under it, blurred (the task column's corner stays
   opaque so header cells slide under it cleanly). */
.tl-headrow {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  height: var(--tl-head-h);
  background: var(--glass-sheen), var(--mat-regular);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow: 0 0.5px 0 var(--line);
}
.tl-corner {
  position: sticky;
  left: 0;
  z-index: 8;
  display: flex;
  flex: none;
  align-items: flex-end;
  gap: 6px;
  width: var(--tl-left-w);
  padding: 0 12px 10px 16px;
  box-shadow: inset -0.5px 0 0 var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.tl-corner__count {
  color: var(--text-3);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}
.tl-head {
  position: relative;
  flex: none;
  width: calc(var(--tl-days) * var(--tl-day));
}
.tl-head__set {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.schedule[data-zoom="day"] .tl-head__set--day,
.schedule[data-zoom="week"] .tl-head__set--week,
.schedule[data-zoom="auto"] .tl-head__set--week,
.schedule[data-zoom="month"] .tl-head__set--month {
  display: flex;
}
@media (max-width: 767px) {
  .schedule[data-zoom="auto"] .tl-head__set--week {
    display: none;
  }
  .schedule[data-zoom="auto"] .tl-head__set--month {
    display: flex;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .schedule.is-zooming .tl-head__set {
    animation: tl-head-in var(--dur-3) var(--ease-out);
  }
  @keyframes tl-head-in {
    from {
      opacity: 0;
    }
  }
}
.tl-head__row {
  position: relative;
  flex: 1 1 auto;
}
.tl-head__row--top {
  flex: 0 0 var(--tl-head-top-h);
  box-shadow: inset 0 -1px 0 var(--tl-grid-line);
}
.tl-hcell {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--tl-x) * var(--tl-day));
  width: calc(var(--tl-w) * var(--tl-day));
  display: flex;
  align-items: center;
  overflow: clip;
  box-shadow: inset 1px 0 0 var(--tl-grid-line);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.tl-hcell__label {
  position: sticky;
  left: calc(var(--tl-left-w) + 2px);
  padding: 0 10px;
}
.tl-hcell__label::first-letter {
  text-transform: uppercase;
}
.tl-hcell--sub {
  color: var(--text-2);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}
.tl-hcell--sub.is-today {
  color: var(--danger-ink);
  font-weight: var(--fw-semibold);
}
.tl-hday {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--tl-x) * var(--tl-day));
  width: var(--tl-day);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.tl-hday__wd {
  font-size: 9.5px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.75;
}
.tl-hday__n {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}
.tl-hday.is-weekend {
  background: var(--tl-weekend-fill);
  color: var(--text-3);
}
/* Today: the red of the "now" line (macOS Calendar). */
.tl-hday.is-today {
  color: var(--danger-ink);
}
.tl-hday.is-today .tl-hday__n {
  background: var(--danger-solid);
  color: var(--text-on-accent);
}
/* r4 · 12.10: a red date capsule on the header's bottom edge, on top of the red "now" line. */
.tl-now {
  position: absolute;
  bottom: 0;
  left: calc((var(--tl-x) + 0.5) * var(--tl-day));
  z-index: 2;
  width: 0;
  pointer-events: none;
}
.tl-now__pill {
  position: absolute;
  bottom: -9px;
  left: 0;
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: var(--radius-full);
  background: var(--danger-solid);
  box-shadow:
    0 0 0 1.5px var(--surface),
    0 1px 3px color-mix(in srgb, var(--danger-solid) 40%, transparent);
  color: var(--text-on-accent);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: translateX(-50%);
}
.schedule[data-zoom="day"] .tl-now {
  display: none;
}

/* Body background: weekends, week / day grid, month lines, the today line */
.tl-body {
  position: relative;
}
.tl-bg {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--tl-left-w);
  z-index: 0;
  width: calc(var(--tl-days) * var(--tl-day));
  pointer-events: none;
  background-image:
    linear-gradient(
      90deg,
      transparent 0 calc(var(--tl-day) * 5),
      var(--tl-weekend-fill) calc(var(--tl-day) * 5) calc(var(--tl-day) * 7)
    ),
    linear-gradient(90deg, var(--tl-grid-line) 0 1px, transparent 1px);
  background-position:
    calc(var(--tl-wk-shift) * var(--tl-day)) 0,
    calc(var(--tl-wk-shift) * var(--tl-day)) 0;
  background-size:
    calc(var(--tl-day) * 7) 100%,
    calc(var(--tl-day) * 7) 100%;
}
.schedule[data-zoom="day"] .tl-bg {
  background-image:
    linear-gradient(
      90deg,
      transparent 0 calc(var(--tl-day) * 5),
      var(--tl-weekend-fill) calc(var(--tl-day) * 5) calc(var(--tl-day) * 7)
    ),
    linear-gradient(90deg, var(--tl-grid-line) 0 1px, transparent 1px);
  background-position:
    calc(var(--tl-wk-shift) * var(--tl-day)) 0,
    0 0;
  background-size:
    calc(var(--tl-day) * 7) 100%,
    var(--tl-day) 100%;
}
.schedule[data-zoom="month"] .tl-bg {
  background-image: none;
}
@media (max-width: 767px) {
  .schedule[data-zoom="auto"] .tl-bg {
    background-image: none;
  }
}
.tl-mline {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--tl-x) * var(--tl-day));
  width: 1px;
  background: var(--line-strong);
  opacity: 0.7;
}
/* r4 · 12.10: the "now" line — 1.5px system red, above the lanes' backgrounds, under the bars. */
.tl-today {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc((var(--tl-x) + 0.5) * var(--tl-day) - 0.75px);
  z-index: 1;
  width: 1.5px;
  background: var(--tl-now);
}
@media (prefers-reduced-motion: no-preference) {
  .tl-today.is-pulse {
    animation: tl-pulse 900ms var(--ease-out);
  }
  @keyframes tl-pulse {
    0% {
      box-shadow: 0 0 0 0 color-mix(in srgb, var(--tl-now) 40%, transparent);
    }
    40% {
      box-shadow: 0 0 0 5px color-mix(in srgb, var(--tl-now) 30%, transparent);
    }
    100% {
      box-shadow: 0 0 0 0 transparent;
    }
  }
}

/* Rows: sticky task cell + lane */
.tl-row,
.tl-group__head {
  position: relative;
  display: flex;
  height: var(--tl-row-h);
}
.tl-row {
  box-shadow: inset 0 -1px 0 var(--tl-row-line);
}
.tl-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  flex: none;
  align-items: center;
  gap: 9px;
  width: var(--tl-left-w);
  min-width: 0;
  padding: 0 8px 0 18px;
  box-shadow:
    inset -1px 0 0 var(--line),
    inset 0 -1px 0 var(--tl-row-line);
  background: var(--surface);
}
.tl-lane {
  position: relative;
  flex: none;
  width: calc(var(--tl-days) * var(--tl-day));
}
/* Scrolled sideways: the frozen task column casts a soft shadow over the lanes. */
.tl-corner::after,
.tl-cell::after {
  content: "";
  position: absolute;
  top: 0;
  right: -10px;
  bottom: 0;
  width: 10px;
  background: linear-gradient(
    90deg,
    light-dark(color-mix(in srgb, var(--text) 9%, transparent), color-mix(in srgb, var(--bg) 55%, transparent)),
    transparent
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-2) ease;
}
.tl-scroll.is-scrolled-x .tl-corner::after,
.tl-scroll.is-scrolled-x .tl-cell::after {
  opacity: 1;
}
.tl-row:hover .tl-cell,
.tl-row:focus-within .tl-cell {
  background: var(--tl-hover);
}
.tl-row:hover .tl-lane,
.tl-row:focus-within .tl-lane {
  background: color-mix(in srgb, var(--fill-1) 55%, transparent);
}
.tl-row.is-current .tl-cell {
  background: light-dark(
    color-mix(in srgb, var(--accent) 8%, var(--surface)),
    color-mix(in srgb, var(--accent) 16%, var(--surface))
  );
  box-shadow:
    inset 3px 0 0 var(--accent),
    inset -1px 0 0 var(--line),
    inset 0 -1px 0 var(--tl-row-line);
}
.tl-row.is-current .tl-lane {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.tl-status {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tone);
}
.tl-status--done {
  width: 15px;
  height: 15px;
  margin-inline: -3px;
  background: var(--success);
  color: var(--text-on-accent);
}
.tl-status--milestone {
  width: 15px;
  height: 15px;
  margin-inline: -3px;
  background: none;
  color: var(--tone);
}
.tl-status--milestone .icon {
  fill: currentColor;
}
.tl-cell__title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-cell__title:hover {
  color: var(--accent-ink);
}
.tl-cell__title:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tl-row.is-done .tl-cell__title {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, currentColor 50%, transparent);
}
.tl-cell__avatar,
.tl-cell__priority {
  display: inline-flex;
  flex-shrink: 0;
}
.tl-cell__dates {
  flex-shrink: 0;
  margin: 0 -2px 0 -4px;
  color: var(--text-2);
  opacity: 0;
  transition: opacity var(--dur-1) ease;
}
.tl-row:hover .tl-cell__dates,
.tl-cell__dates:focus-visible,
.tl-group--unscheduled .tl-cell__dates {
  opacity: 1;
}
@media (hover: none) {
  .tl-cell__dates {
    opacity: 1;
  }
}

/* Group headers: tinted band, sticky label, summary bar across the group's span */
.tl-group__head {
  z-index: 2;
}
.tl-cell--group {
  padding-left: 8px;
  background: var(--tl-band);
}
.tl-lane--group {
  background: color-mix(in srgb, var(--fill-1) 55%, transparent);
  box-shadow: inset 0 -1px 0 var(--tl-row-line);
}
.tl-group__toggle {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-align: left;
  transition: background-color var(--dur-1) ease;
}
.tl-group__toggle:hover {
  background: var(--fill-1);
}
.tl-group__toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tl-group__chev {
  flex-shrink: 0;
  color: var(--text-3);
  transition: transform var(--dur-2) var(--ease-out);
}
.tl-group.is-collapsed .tl-group__chev {
  transform: rotate(-90deg);
}
.tl-group.is-collapsed .tl-row {
  display: none;
}
.tl-group__dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tone);
}
.tl-group__icon {
  flex: none;
  color: var(--text-2);
}
.tl-group__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-group__count {
  flex: none;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--fill-1);
  color: var(--text-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.tl-sum {
  position: absolute;
  top: calc(50% - 3px);
  left: calc(var(--tl-x) * var(--tl-day));
  width: max(calc(var(--tl-w) * var(--tl-day)), 6px);
  height: 6px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--tone) 42%, transparent);
  opacity: 0.75;
}
.tl-sum::before,
.tl-sum::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 2px;
  height: 12px;
  border-radius: 1px;
  background: color-mix(in srgb, var(--tone) 70%, transparent);
}
.tl-sum::before {
  left: 0;
}
.tl-sum::after {
  right: 0;
}
.tl-lane__hint {
  position: sticky;
  left: calc(var(--tl-left-w) + 12px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 12px;
  color: var(--text-3);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

/* Bars */
/* r4 · 12.10: 22px rounded bars in the status tone — a soft tint with ink text (AA on every palette
   tone, both themes) and a deeper tint for the done part (subtasks done / total; completed
   tasks are full). Hover lifts the bar 1px with --shadow-md (the individual `translate` property, so
   it composes with the land / pop animations). */
.tl-bar {
  --tl-bar-bg: light-dark(
    color-mix(in srgb, var(--tone) 22%, var(--surface)),
    color-mix(in srgb, var(--tone) 30%, var(--surface))
  );
  --tl-bar-fill: light-dark(
    color-mix(in srgb, var(--tone) 36%, var(--surface)),
    color-mix(in srgb, var(--tone) 42%, var(--surface))
  );
  --tl-bar-line: color-mix(in srgb, var(--tone) 48%, transparent);
  --tl-bar-shadow: 0 0.5px 1px color-mix(in srgb, var(--tone) 22%, transparent);
  position: absolute;
  top: calc((var(--tl-row-h) - var(--tl-bar-h)) / 2);
  left: calc(var(--tl-x) * var(--tl-day) + 1px);
  z-index: 2;
  display: flex;
  align-items: center;
  width: max(calc(var(--tl-w) * var(--tl-day) - 2px), 6px);
  height: var(--tl-bar-h);
  border-radius: var(--tl-bar-radius);
  background: var(--tl-bar-bg);
  box-shadow:
    inset 0 0 0 0.5px var(--tl-bar-line),
    var(--tl-bar-shadow);
  /* The tone's ink, pulled toward --text so labels keep AA on the progress tint too (gray / yellow). */
  color: light-dark(color-mix(in srgb, var(--tone-ink) 72%, var(--text)), color-mix(in srgb, var(--tone-ink) 35%, var(--text)));
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition:
    box-shadow var(--dur-2) var(--ease-out),
    translate var(--dur-snappy) var(--spring-snappy),
    opacity var(--dur-2) ease,
    filter var(--dur-2) ease;
}
.tl-bar[data-movable] {
  cursor: grab;
}
@media (hover: hover) {
  .tl-bar:not(.tl-bar--milestone):hover {
    box-shadow:
      inset 0 0 0 0.5px color-mix(in srgb, var(--tone) 60%, transparent),
      var(--shadow-md);
    translate: 0 -1px;
  }
}
.tl-bar:focus-visible {
  outline: none;
  box-shadow:
    inset 0 0 0 0.5px var(--tl-bar-line),
    0 0 0 2px var(--surface),
    0 0 0 4px var(--focus-outline);
}
.tl-bar.is-current {
  box-shadow:
    inset 0 0 0 0.5px var(--tl-bar-line),
    0 0 0 2px var(--surface),
    0 0 0 4px var(--accent),
    var(--shadow-sm);
}
.tl-bar__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--tl-bar-fill);
  clip-path: inset(0 calc(100% - var(--tl-p, 0%)) 0 0);
  pointer-events: none;
}
.tl-bar__label {
  position: sticky;
  left: calc(var(--tl-left-w) + 4px);
  z-index: 1;
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  padding: 0 9px;
  overflow: hidden;
  pointer-events: none;
}
.tl-bar__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-bar__check {
  flex: none;
  margin-right: 4px;
  color: var(--tone-ink);
}
/* Labels that don't fit (per zoom level, see data-fit) sit outside, to the right of the bar —
   or of its overdue line. Milestones always label to the right. */
.tl-bar--milestone .tl-bar__label,
.schedule[data-zoom="day"] .tl-bar:not([data-fit~="day"]) .tl-bar__label,
.schedule[data-zoom="week"] .tl-bar:not([data-fit~="week"]) .tl-bar__label,
.schedule[data-zoom="auto"] .tl-bar:not([data-fit~="week"]) .tl-bar__label,
.schedule[data-zoom="month"] .tl-bar:not([data-fit~="month"]) .tl-bar__label {
  position: absolute;
  left: calc(100% + 6px + var(--tl-slip-w, 0px));
  padding: 0;
  overflow: visible;
  color: var(--text-2);
}
.tl-bar--open .tl-bar__label {
  position: absolute;
  left: calc(100% + 6px);
  padding: 0;
  overflow: visible;
  color: var(--text-2);
}
.tl-bar[data-slip] {
  --tl-slip-w: calc((var(--tl-slip) - 0.5) * var(--tl-day) + 6px);
}
.tl-bar__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  width: 10px;
  cursor: ew-resize;
  touch-action: none;
}
.tl-bar__handle--start {
  left: -2px;
}
.tl-bar__handle--end {
  right: -2px;
}
.tl-bar__handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 2px;
  height: 10px;
  border-radius: 1px;
  background: var(--tone-ink);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity var(--dur-1) ease;
}
.tl-bar:hover .tl-bar__handle::after,
.tl-bar.is-dragging .tl-bar__handle::after {
  opacity: 0.6;
}
/* Narrow bars: no grips (the whole bar moves; resize with Alt+Shift+arrows or the date popover) */
.schedule[data-zoom="month"] .tl-bar__handle,
.schedule[data-zoom="auto"] .tl-bar[data-w="1"] .tl-bar__handle,
.schedule[data-zoom="week"] .tl-bar[data-w="1"] .tl-bar__handle {
  display: none;
}
.tl-bar.is-done {
  --tl-bar-fill: light-dark(
    color-mix(in srgb, var(--tone) 14%, var(--surface)),
    color-mix(in srgb, var(--tone) 22%, var(--surface))
  );
  --tl-bar-line: color-mix(in srgb, var(--tone) 26%, transparent);
  --tl-bar-shadow: 0 0 0 transparent;
  color: var(--text-2);
}
.tl-bar.is-done .tl-bar__text {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
}
/* Overdue: a dotted line from the due date to today, ending in a dot on the today line */
.tl-bar__slip {
  position: absolute;
  top: 50%;
  left: 100%;
  width: calc((var(--tl-slip) - 0.5) * var(--tl-day));
  height: 0;
  border-top: 2px dotted color-mix(in srgb, var(--danger) 70%, transparent);
  transform: translateY(-1px);
  pointer-events: none;
}
.tl-bar__slip::after {
  content: "";
  position: absolute;
  top: -5px;
  right: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface);
}
.tl-bar.is-clipped-start {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.tl-bar.is-clipped-end {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.tl-bar--open {
  -webkit-mask-image: linear-gradient(90deg, var(--text) 50%, transparent);
  mask-image: linear-gradient(90deg, var(--text) 50%, transparent);
}
.tl-bar--milestone {
  top: calc((var(--tl-row-h) - var(--tl-ms)) / 2);
  left: calc((var(--tl-x) + 0.5) * var(--tl-day) - var(--tl-ms) / 2);
  width: var(--tl-ms);
  height: var(--tl-ms);
  background: none;
  box-shadow: none;
}
.tl-bar--milestone:hover {
  box-shadow: none;
}
.tl-bar--milestone:focus-visible,
.tl-bar--milestone.is-current {
  border-radius: 4px;
  box-shadow: 0 0 0 3px var(--focus-outline);
}
/* r4 · 12.10: milestones are a 14px accent diamond (the status stays in the task column). */
.tl-bar__diamond {
  position: absolute;
  inset: 2px;
  border-radius: 2.5px;
  background: var(--accent);
  box-shadow:
    0 0 0 1.5px var(--surface),
    0 1px 3px color-mix(in srgb, var(--accent) 45%, transparent);
  transform: rotate(45deg);
  transition: transform var(--dur-snappy) var(--spring-bouncy);
}
.tl-bar--milestone:hover .tl-bar__diamond {
  transform: rotate(45deg) scale(1.2);
}
.tl-bar--milestone.is-done .tl-bar__diamond {
  background: color-mix(in srgb, var(--accent) 45%, var(--surface));
}
.tl-bar--milestone.is-overdue .tl-bar__diamond {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 3.5px var(--danger);
}
.tl-bar--milestone .tl-bar__label {
  left: calc(100% + 9px);
  color: var(--text);
  font-weight: var(--fw-semibold);
}
.tl-bar.is-dragging {
  z-index: 5;
  box-shadow:
    inset 0 0 0 0.5px color-mix(in srgb, var(--tone) 60%, transparent),
    var(--shadow-lift);
  translate: 0 -1px;
  cursor: grabbing;
}
.tl-bar--milestone.is-dragging {
  box-shadow: none;
}
.tl-bar.is-dragging {
  --tl-slip-w: 0px;
}
.tl-bar.is-dragging .tl-bar__slip {
  display: none;
}
.tl-bar.is-saving {
  opacity: 0.72;
}
@media (prefers-reduced-motion: no-preference) {
  .tl-bar.is-reverting {
    transition:
      left var(--dur-3) var(--ease-spring),
      width var(--dur-3) var(--ease-spring);
  }
  .tl-bar.is-landed {
    animation: tl-land var(--dur-3) var(--ease-spring);
  }
  @keyframes tl-land {
    40% {
      transform: scale(1.04);
    }
  }
  /* Bars draw in from their start when they first appear (page load, new tasks). */
  .tl-bar--bar,
  .tl-bar--open {
    animation: tl-grow var(--dur-4) var(--ease-out) backwards;
  }
  .tl-bar--milestone {
    animation: tl-pop var(--dur-3) var(--ease-spring) backwards;
  }
  @keyframes tl-grow {
    from {
      clip-path: inset(-12px 100% -12px -12px);
    }
    to {
      clip-path: inset(-12px -100vw -12px -12px);
    }
  }
  @keyframes tl-pop {
    from {
      opacity: 0;
      transform: scale(0.4);
    }
  }
}
/* Just created / scheduled: a soft accent ring pulses once (schedule.js adds .is-new). */
@media (prefers-reduced-motion: no-preference) {
  .tl-bar.is-new,
  .cal-chip.is-new {
    animation: sched-flash 1.2s var(--ease-out);
  }
  @keyframes sched-flash {
    0% {
      box-shadow: 0 0 0 0 var(--focus-ring);
    }
    25% {
      box-shadow: 0 0 0 6px var(--focus-ring);
    }
    100% {
      box-shadow: 0 0 0 0 transparent;
    }
  }
}
/* Where the bar started (while dragging) */
.tl-bar-ghost {
  position: absolute;
  top: calc((var(--tl-row-h) - var(--tl-bar-h)) / 2);
  left: calc(var(--tl-x) * var(--tl-day) + 1px);
  z-index: 1;
  width: max(calc(var(--tl-w) * var(--tl-day) - 2px), 6px);
  height: var(--tl-bar-h);
  border: 1.5px dashed color-mix(in srgb, var(--tone) 55%, transparent);
  border-radius: var(--tl-bar-radius);
  background: color-mix(in srgb, var(--tone) 6%, transparent);
  pointer-events: none;
}
.tl-bar-ghost--milestone {
  left: calc((var(--tl-x) + 0.5) * var(--tl-day) - var(--tl-ms) / 2);
  top: calc((var(--tl-row-h) - var(--tl-ms)) / 2);
  width: var(--tl-ms);
  height: var(--tl-ms);
  border-radius: 3px;
  transform: rotate(45deg);
}
/* Live dates while dragging / resizing */
.tl-drag-label {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 0;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--tooltip-bg);
  box-shadow: var(--shadow-md);
  color: var(--tooltip-fg);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.tl-drag-label__days {
  opacity: 0.7;
  font-weight: var(--fw-medium);
}
.tl-bar[data-drag-mode="end"] .tl-drag-label {
  left: auto;
  right: 0;
}

/* Unscheduled lanes: a ghost bar follows the pointer; click = that day, drag = a range */
.tl-lane--place {
  cursor: copy;
}
.tl-ghost {
  position: absolute;
  top: calc((var(--tl-row-h) - var(--tl-bar-h)) / 2);
  left: calc(var(--tl-gx, 0) * var(--tl-day) + 1px);
  display: flex;
  align-items: center;
  width: max(calc(var(--tl-gw, 1) * var(--tl-day) - 2px), 10px);
  height: var(--tl-bar-h);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 70%, transparent);
  border-radius: var(--tl-bar-radius);
  background: var(--accent-softer);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-1) ease;
}
.tl-lane--place.is-hovering .tl-ghost,
.tl-lane--place.is-placing .tl-ghost {
  opacity: 1;
}
.tl-lane--place.is-placing .tl-ghost {
  border-style: solid;
  background: var(--accent-soft);
}
.tl-ghost__label {
  position: absolute;
  left: calc(100% + 8px);
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  background: var(--tooltip-bg);
  color: var(--tooltip-fg);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tl-ghost__label:empty {
  display: none;
}

/* Nothing to draw: a centred empty state over a quiet canvas (no grid, no today line). */
.tl-scroll:has(.tl-empty) {
  container: tl-scroll / inline-size;
}
.tl-body:has(.tl-empty) .tl-bg {
  display: none;
}
.tl-empty {
  position: sticky;
  left: 0;
  width: 100cqi;
  max-width: 100%;
  padding: var(--space-12) var(--space-4);
}

/* "Show N more" row at the end of a long group (rows are capped per group). */
.tl-row--more .tl-cell {
  padding-left: 12px;
}
.tl-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--accent-ink);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
  white-space: nowrap;
}
.tl-more:hover {
  background: var(--accent-softer);
}
.tl-more:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Tooltip (one element, created by schedule.js) — timeline bars and calendar chips */
.tl-tip {
  position: fixed;
  z-index: var(--z-tooltip);
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 8px 11px 9px;
  border-radius: var(--radius-md);
  background: var(--tooltip-bg);
  box-shadow: var(--shadow-md);
  color: var(--tooltip-fg);
  font-size: var(--fs-xs);
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px) scale(0.98);
  transform-origin: 50% 100%;
  transition:
    opacity var(--dur-1) ease,
    transform var(--dur-2) var(--ease-out);
}
.tl-tip.is-visible {
  opacity: 1;
  transform: none;
}
.tl-tip__title {
  display: block;
  margin-bottom: 1px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  overflow-wrap: break-word;
}
.tl-tip__line {
  display: block;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}
/* The tooltip is inverse (dark on light pages, light on dark ones): mix the red toward its text. */
.tl-tip__line--alert {
  color: color-mix(in srgb, var(--danger) 65%, var(--tooltip-fg));
  opacity: 1;
  font-weight: var(--fw-semibold);
}

/* Phones: no task column — each row shows its title (sticky at the left edge) above its bar */
@media (max-width: 767px) {
  .tl {
    --tl-left-w: 0px;
    --tl-row-h: 58px;
    --tl-title-h: 24px;
    --tl-bar-h: 18px;
    --tl-ms: 13px;
    --tl-head-h: 52px;
    --tl-bar-radius: 6px;
    border-radius: var(--radius-md);
  }
  .tl-corner {
    display: none;
  }
  .tl-cell::after {
    display: none;
  }
  .tl-row,
  .tl-group__head {
    display: block;
  }
  .tl-cell {
    width: max-content;
    max-width: calc(100vw - 2 * var(--page-pad-x) - 24px);
    height: var(--tl-title-h);
    gap: 7px;
    margin-top: 5px;
    padding: 0 14px 0 12px;
    box-shadow: none;
    background: var(--surface);
    -webkit-mask-image: linear-gradient(90deg, var(--text) calc(100% - 10px), transparent);
    mask-image: linear-gradient(90deg, var(--text) calc(100% - 10px), transparent);
  }
  .tl-row:hover .tl-cell,
  .tl-row:focus-within .tl-cell {
    background: var(--surface);
    box-shadow: none;
  }
  .tl-row.is-current .tl-cell {
    box-shadow: inset 3px 0 0 var(--accent);
  }
  .tl-cell--group {
    margin-top: 0;
    background: var(--tl-band);
    -webkit-mask-image: none;
    mask-image: none;
  }
  .tl-row .tl-lane {
    position: absolute;
    top: calc(var(--tl-title-h) + 5px);
    bottom: 0;
    left: 0;
  }
  .tl-row .tl-bar,
  .tl-row .tl-bar-ghost,
  .tl-row .tl-ghost {
    top: calc((var(--tl-row-h) - var(--tl-title-h) - 5px - var(--tl-bar-h)) / 2 - 2px);
  }
  .tl-row .tl-bar--milestone,
  .tl-row .tl-bar-ghost--milestone {
    top: calc((var(--tl-row-h) - var(--tl-title-h) - 5px - var(--tl-ms)) / 2 - 2px);
  }
  .tl-bar .tl-bar__label {
    display: none;
  }
  .tl-cell__title {
    font-size: var(--fs-sm);
  }
  .tl-cell__avatar,
  .tl-cell__priority,
  .tl-cell__dates {
    display: none;
  }
  .tl-group--unscheduled .tl-cell__dates {
    display: inline-flex;
    margin-block: -8px;
  }
  .tl-group__head {
    height: 44px;
  }
  .tl-cell--group {
    height: 100%;
    padding: 0 8px;
  }
  .tl-group__head .tl-lane {
    position: absolute;
    inset: 0 auto 0 0;
  }
  .tl-group__toggle {
    flex: none;
  }
  .tl-row.is-done .tl-cell__title {
    text-decoration: none;
  }
  .tl-lane__hint {
    display: none;
  }
  .tl-hcell__label {
    left: 2px;
  }
  .tl-scroll {
    scrollbar-gutter: auto;
  }
}

/* -- Date popover ---------------------------------------------------------------------------------- */
.sched-pop {
  width: min(320px, calc(100vw - 16px));
  padding: 14px;
}
.sched-pop__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sched-pop__head {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-right: 32px;
}
.sched-pop__close {
  position: absolute;
  top: -6px;
  right: -6px;
  color: var(--text-2);
}
.sched-pop__eyebrow {
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}
.sched-pop__title {
  display: -webkit-box;
  overflow: hidden;
  font-weight: var(--fw-semibold);
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.sched-pop__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
}
.sched-pop__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.sched-pop__label {
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}
.sched-pop__field .input {
  width: 100%;
  min-width: 0;
}
.sched-pop__error {
  color: var(--danger-ink);
  font-size: var(--fs-xs);
}
.sched-pop__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.sched-pop__clear {
  margin-left: -8px;
  color: var(--text-2);
}

/* -- Responsive ------------------------------------------------------------------------------------ */
/* Narrow month cells (tablets, small laptops): titles first — chips wrap to two lines and drop
   the priority glyph (it stays in week cards, agenda rows, hover cards and the drawer). */
@media (max-width: 1279px) {
  .cal--month .cal-chip .priority {
    display: none;
  }
  .cal--month .cal-chip {
    align-items: flex-start;
    height: auto;
    min-height: 20px;
    padding-block: 3px;
    padding-inline: 7px 4px;
    gap: 4px;
  }
  .cal--month .cal-chip__icon {
    margin-top: 1px;
  }
  .cal--month .cal-chip__title {
    display: -webkit-box;
    font-size: var(--fs-2xs);
    line-height: 1.3;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow-wrap: break-word;
  }
}
@media (max-width: 1023px) {
  .cal-wday {
    padding-inline: 4px;
  }
  .cal-wday__head {
    margin-inline: -4px;
    padding-inline: 8px;
  }
  .cal-chip--card {
    padding: 7px 6px 6px 9px;
  }
  .cal-chip--card .cal-chip__title {
    font-size: var(--fs-xs);
    line-height: 1.3;
  }
  .cal-chip--card .cal-chip__status {
    display: none;
  }
}
@media (max-width: 519px) {
  .sched-toggle__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .sched-toggle {
    padding-inline: 8px;
  }
}
@media (max-width: 767px) {
  .schedule {
    gap: var(--space-3);
  }
  .sched-toolbar__lead {
    flex-basis: 100%;
    justify-content: space-between;
  }
  .schedule--calendar .sched-toolbar__lead {
    flex-direction: row-reverse;
  }
  /* Timeline: ‹ Today › and the zoom switch share one row (there is no period title) — the zoom
     switch drops to its own row only when long labels (ru "Неделя · Месяц") can't fit at 360. */
  .schedule--timeline .sched-toolbar {
    flex-wrap: wrap;
  }
  .schedule--timeline .sched-seg__item {
    min-width: 0;
    padding-inline: 12px;
  }
  .schedule--timeline .sched-toolbar__lead {
    flex: 0 0 auto;
  }
  .schedule--timeline .sched-toolbar__tools {
    flex: 0 1 auto;
    margin-left: auto; /* stays on the right when it wraps */
  }
  .sched-title {
    font-size: var(--fs-title-3);
  }
  .sched-toolbar__tools {
    flex: 1 1 auto;
  }
  .sched-seg {
    margin-left: auto;
  }
  .sched-seg__item {
    min-width: 0;
    padding: 0 11px;
  }
  /* iOS: the Month | Week switch spans the width under the title. */
  .schedule--calendar .sched-seg {
    flex: 1 1 auto;
    margin-left: 0;
  }
  .schedule--calendar .sched-seg__item {
    flex: 1 1 0;
  }
}
@media (pointer: coarse) {
  .sched-seg__item {
    height: calc(var(--control-h-sm) - 2px);
  }
  .cal-day__more {
    height: 28px;
  }
}
