/* ---------------------------------------------------------------------------
   Stage three: Sent, or the sending calendar
   ---------------------------------------------------------------------------
   A segmented control rather than two tabs, because these are two views of one
   stage rather than two places to be. It sits at the right of the stage header
   where the Add button sits on the stages above, so the header keeps one shape
   all the way down the page.
   --------------------------------------------------------------------------- */

/* The two halves are two filters over the same stage, which is what the four
   periods on Replies are — so they are drawn the same way: free-standing .chip
   pills in a row, each with its own border, the selected one filled with ink.
   They shared one enclosing track before, which read as a segmented control:
   a different idea, and the only one of its kind in the app. */
.stagetoggle { margin-left: auto; display: inline-flex }

.cal { display: block }
.cal__key { display: flex; align-items: center; gap: 16px; flex-wrap: wrap }
.cal__keyitem { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted) }
.cal__keyitem .cal__chip:last-of-type { margin-right: 2px }
.cal__swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block }
.cal__swatch--free { background: var(--line) }

/* One card with hairlines through it, matching the sent table it shares the
   stage with: same surface, same border, same 24px radius, same grey header
   strip. It was thirty separately outlined tiles floating on the page colour,
   which read as a different component belonging to a different screen.

   Five columns, Monday to Friday. Weekends are not hidden to save space — they
   are genuinely not sending days, and a row of permanently empty cells would
   suggest otherwise. */
.cal__card { background: var(--card); border: 1px solid var(--line); border-radius: 24px; overflow: hidden }
/* The key sits in the same grey strip the sent table puts its column names in,
   so the two stages read as one component seen two ways. */
.cal__head { background: var(--page); padding: 13px 26px }
.cal__grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--hair);
}
.cal__dow {
  background: var(--page); padding: 14px 16px;
  font-size: 11.5px; font-weight: var(--weight-strong); color: var(--muted);
  letter-spacing: .02em; border-left: 1px solid var(--hair);
}
.cal__day {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  min-height: 104px; padding: 13px 16px; text-align: left; cursor: pointer;
  background: var(--card); border: none;
  border-top: 1px solid var(--hair); border-left: 1px solid var(--hair);
  font-family: inherit; color: var(--text);
  transition: background .16s ease;
}
/* Five day-name cells come first, so every fifth child from the first is the
   Monday column — header included, which is exactly what wants no left edge. */
.cal__grid > :nth-child(5n + 1) { border-left: none }
.cal__day:hover:not(:disabled) { background: var(--page) }
.cal__day:disabled { cursor: default }
.cal__day--past { opacity: .5 }
.cal__day--today { box-shadow: inset 0 0 0 2px var(--ink) }
.cal__day--picked { box-shadow: inset 0 0 0 2px var(--teal) }
.cal__day--picked:hover { background: var(--card) }

.cal__date { display: flex; align-items: baseline; gap: 5px }
.cal__date b { font-size: 15px; font-weight: var(--weight-strong) }
.cal__date span { font-size: 11px; color: var(--muted) }

/* One bar, three segments, sized by count. The shape of the day is readable
   without reading the numbers, which is the whole point of putting six weeks on
   one screen. */
.cal__bar { display: flex; gap: 2px; height: 10px; margin-bottom: 10px }
.cal__seg { display: block; border-radius: 99px; min-width: 3px }
/* The stage ramp on the bar, the same four --stage-N the chips and tags wear.
   One source, so a stage cannot be one colour in the key and another in the bar
   underneath it. A day then reads left to right as "one new conversation, then
   the tail of the ones started before it" — and reads it in hue, which survives
   being 6px tall better than four shades of the same grey did. */
.cal__seg--1 { background: var(--stage-1) }
.cal__seg--2 { background: var(--stage-2) }
.cal__seg--3 { background: var(--stage-3) }
.cal__seg--4 { background: var(--stage-4) }
.cal__seg--free { background: var(--line) }

/* One line, four possible entries, only the non-zero ones drawn. The day detail
   keeps this form; the cell uses the column below. */
.cal__stages { display: flex; align-items: center; gap: 7px; flex-wrap: wrap }
.cal__stage { display: inline-flex; align-items: center; gap: 3px }
.cal__stage b { font-size: 11.5px; font-weight: var(--weight-strong) }

/* The cell's column: chip, name, count, one stage per line.
   Three explicit tracks rather than a flex row, so the counts land on one right
   edge and the names start on one left edge in every cell of the grid — the
   whole reason for stacking them. The middle track is the one that gives when a
   column is narrow, and it ellipsises rather than wrapping, because a name that
   wraps takes its row's count with it and the alignment is gone. */
.cal__rows { display: flex; flex-direction: column; gap: 3px }
.cal__stagerow {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center; gap: 8px; font-size: 11.5px;
}
/* The name is the flexible track and the only one allowed to be cut. The metric
   beside it is the row's whole payload — a step's name is recoverable from the
   chip and the key, "4 emails · 3 people" is not recoverable from anything. */
.cal__stagename {
  color: var(--muted); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal__stagemetric { color: var(--muted); white-space: nowrap }
.cal__stagemetric b {
  color: var(--text); font-weight: var(--weight-strong);
  font-variant-numeric: tabular-nums;
}
.cal__chip {
  display: inline-grid; place-items: center; width: 14px; height: 14px;
  border-radius: 4px; font-size: 9.5px; font-weight: var(--weight-strong);
  font-style: normal; line-height: 1; flex: 0 0 14px;
}
.cal__free { font-size: 11px; color: var(--muted); margin-top: 7px }
/* One span per part, so the line wraps between them and never through one. */
.cal__free span { white-space: nowrap }
.cal__closed { font-size: 11.5px; color: var(--muted) }
.cal__closed .ms { font-size: 18px; opacity: .6 }
/* The day in one number. Muted while there is room, ink when the day is full. */
.cal__sum { display: flex; align-items: center; gap: 10px; color: var(--muted) }
.cal__sum b { font-size: 20px; font-weight: var(--weight-strong); font-variant-numeric: tabular-nums; letter-spacing: -.02em }
.cal__sum--full { color: var(--text) }
.cal__senders { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: var(--weight-strong) }
.cal__senders .ms { font-size: 15px }
.cal__warn { margin-left: auto; font-size: 17px; color: #C0362C }

.cal__detail {
  margin-top: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 24px; padding: 18px 26px;
}
.cal__detailhead { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap }
.cal__detailhead b { font-size: 15px; font-weight: var(--weight-strong) }
.cal__detailhead .closer { margin-left: auto }
.cal__daysum { display: inline-flex; gap: 12px; font-variant-numeric: tabular-nums }
.cal__daysum span { display: inline-flex; align-items: center; gap: 4px }
.cal__daysum .ms { font-size: 16px }
/* The empty calendar: two weeks of blank days, drawn rather than described. */
.cal__card--ghost { opacity: .7 }
/* A day nobody can send on: nothing to open. */
.cal__day--closed { cursor: default }
.cal__list { display: flex; flex-direction: column }
.cal__item {
  display: grid; grid-template-columns: 104px minmax(0, 1.6fr) minmax(0, 1fr) auto;
  gap: 14px; align-items: center; padding: 9px 0;
  border-top: 1px solid var(--hair); font-size: 13px;
}
.cal__item:first-child { border-top: none }
.cal__tag {
  font-size: 11.5px; font-weight: var(--weight-strong); color: var(--muted);
  text-align: center; white-space: nowrap;
}
.cal__from { font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

/* The stage ramp again, for the two things that carry a digit or a word. Taken
   straight, with the foreground each fill was checked against — nothing mixed
   or faded, because a 9.5px bold digit on a washed-out square is a smudge,
   which is what the old ink ramp made of stages 3 and 4.
   Declared after .cal__chip and .cal__tag, not with the bar: both set their own
   background, and at equal specificity the later rule wins. */
.cal__chip--1 { background: var(--stage-1); color: var(--on-stage-1) }
.cal__tag--1 { --dot: var(--stage-1) }
.cal__chip--2 { background: var(--stage-2); color: var(--on-stage-2) }
.cal__tag--2 { --dot: var(--stage-2) }
.cal__chip--3 { background: var(--stage-3); color: var(--on-stage-3) }
.cal__tag--3 { --dot: var(--stage-3) }
.cal__chip--4 { background: var(--stage-4); color: var(--on-stage-4) }
.cal__tag--4 { --dot: var(--stage-4) }
/* A stage name in the calendar list: the stage's colour as a dot, the name beside it. */
.cal__tag { display: inline-flex; align-items: center; gap: 6px }
.cal__tag::before { content: ""; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--muted)) }
.cal__who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.cal__status { font-size: 12px; white-space: nowrap }

/* On a phone the week grid stops being a grid: five columns of 60px tell you
   nothing. One day per row, with the same bar, reads as a list of what is
   coming — which is what a calendar is for on a small screen anyway. */
@media (max-width: 720px) {
  .cal__grid { grid-template-columns: minmax(0, 1fr) }
  .cal__dow { display: none }
  .cal__day {
    min-height: 0; flex-direction: row; align-items: center; gap: 14px;
    border-left: none;
  }
  /* Once the day names are hidden the first day cell sits on the card's own top
     edge and must not draw a second line under it. Addressed by position, not
     by :first-child: the five day-name cells are still in the DOM, just not
     displayed, so the grid's first child is one of those. */
  .cal__grid > .cal__day:nth-child(6) { border-top: none }
  .cal__day > div:last-child { flex: 1 1 auto; min-width: 0 }
  .cal__date { flex: 0 0 54px; gap: 6px }
  .cal__free { margin-top: 2px }
  .cal__item { grid-template-columns: minmax(0, 1fr); gap: 3px }
  .cal__tag { justify-self: start }
}
