/* ============================================================================
   UI STEP 7 (2026-10-12) — Results, the Calendar, Today's figures and the
   first run: results-view.js, calendar-view.js, today.js, first-run.js.
   ----------------------------------------------------------------------------
   After work.css, whose Shop page these two pages are laid out like: their own
   scroll, the same 80px head room under the top bar and the same wash at the
   top, so going from Today or the Shop to Results moves nothing that was
   already in place — the rail, the top bar and the chat keep their tracks.

   Motion is the owner's pack, all tokens: things arrive (4–6px and .96, never
   travel), exits run at 0.7 on the exit curve, lists stagger 18ms for six
   rows, and nothing that shows money moves with the spring. Under reduced
   motion every move is an 80ms fade.
   ============================================================================ */

/* ---------- the two pages' frames ------------------------------------------- */
#results-view, #calendar-view { display: none; }
#app.view-results #results-view, #app.view-calendar #calendar-view { display: flex; }
#app.view-results { --vh: var(--fill-honey); --vw: var(--honey-wash); --vi: var(--honey); }
#app.view-calendar { --vh: var(--fill-denim); --vw: var(--denim-wash); --vi: var(--denim); }
#results-view, #calendar-view {
  flex: 1; min-height: 0; overflow-y: auto; flex-direction: column; padding: 80px 32px 40px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--vw, var(--card-2)) 70%, var(--window)) 0, var(--window) 300px) local;
}
.rs-inner, .cal-inner { width: min(1120px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cal-inner { width: min(1180px, 100%); gap: 12px; }
#results-h, #calendar-h { margin: 0; font-size: clamp(24px, 4cqi, 28px); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }

/* ---------- Results: the head -------------------------------------------------- */
.rs-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rs-head-words { display: grid; gap: 4px; min-width: 0; }
.rs-lede { margin: 0; font-size: 13.5px; color: var(--dim); }
.rs-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.rs-filters:empty { display: none; }
.rs-filt, .td-range-b, .cal-seg {
  min-height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card);
  font: inherit; font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background var(--dur-instant) var(--ease-snap), color var(--dur-instant) var(--ease-snap), border-color var(--dur-instant) var(--ease-snap);
}
.rs-filt:hover, .td-range-b:hover, .cal-seg:hover { border-color: color-mix(in srgb, var(--text) 28%, var(--line-2)); }
.rs-filt[aria-pressed="true"], .td-range-b[aria-pressed="true"], .cal-seg[aria-pressed="true"] {
  background: var(--btn-ink); border-color: var(--btn-ink); color: var(--on-btn-ink);
}
.rs-filt:focus-visible, .td-range-b:focus-visible, .cal-seg:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- Results: the figures ----------------------------------------------- */
.rs-content { display: flex; flex-direction: column; gap: 14px; }
.rs-cards { display: flex; flex-wrap: wrap; gap: 10px; }
.rs-card { background: var(--card); border-radius: var(--card-r); box-shadow: var(--elev-1); padding: 14px 16px; flex: 1 1 150px; min-width: 0; }
.rs-card-h { margin: 0; font-size: 12.5px; font-weight: 500; color: var(--dim); }
.rs-card-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-card-words { white-space: normal; }
.rs-num { margin: 4px 0 0; font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
/* The headline is the canvas's dark card: ink ground, the figure in the
   paper colour. Only what is measured is on it. */
.rs-hero { flex: 2 1 420px; background: var(--btn-ink); color: var(--on-btn-ink); box-shadow: none; }
.rs-hero .rs-card-h { color: color-mix(in srgb, var(--on-btn-ink) 68%, transparent); }
.rs-hero-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin: 6px 0 0; }
.rs-hero .rs-num { margin: 0; font-size: 32px; }
.rs-hero-q { color: color-mix(in srgb, var(--on-btn-ink) 68%, transparent); font-size: 14px; white-space: nowrap; }
.rs-hero-none { font-size: 18px; font-weight: 500; }
.rs-hero-facts { margin: 6px 0 0; font-size: 12.5px; color: color-mix(in srgb, var(--on-btn-ink) 68%, transparent); }

/* ---------- Results: the rows ---------------------------------------------------- */
.rs-table { background: var(--card); border-radius: var(--card-r); box-shadow: var(--elev-1); overflow: hidden; }
.rs-cols, .rs-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 76px 150px 116px 16px; column-gap: 14px; align-items: center;
}
.rs-cols { padding: 10px 16px 9px; font: 500 12px/1 var(--f-body); letter-spacing: normal; text-transform: none; color: var(--dim); }
.rs-cols > :nth-child(4) { text-align: right; }
.rs-list { list-style: none; margin: 0; padding: 0; }
.rs-item { border-top: 1px solid var(--line); }
.rs-row {
  width: 100%; padding: 11px 16px; border: 0; background: none; font: inherit; font-size: var(--t-sm); color: var(--text);
  text-align: left; cursor: pointer; transition: background var(--dur-instant) var(--ease-snap);
}
.rs-row:hover, .rs-row[aria-expanded="true"] { background: var(--card-2); }
.rs-row:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.rs-change { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rs-av { width: 22px; height: 22px; border-radius: 6px; font-size: 10.5px; flex: none; }
/* Scout's own mark for a change made in a chat or by nobody recorded: the
   brand's diamond in ink, so it reads as "Scout" and not as a teammate. */
.rs-av-scout { display: inline-grid; place-items: center; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line); }
.rs-av-scout::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--primary); transform: rotate(45deg); }
.rs-words { display: grid; gap: 1px; min-width: 0; }
.rs-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-sub { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-when { font-size: 12.5px; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rs-who { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-cost { font: 500 12.5px/1.2 var(--f-body); letter-spacing: normal; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.rs-cost[data-none="true"] { color: var(--dim); font-weight: 400; }
.rs-chev { width: 16px; height: 16px; display: grid; place-items: center; color: var(--dim); }
.rs-chev::before {
  content: ""; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform calc(var(--dur-quick) * var(--dur-exit-scale)) var(--ease-exit);
}
.rs-row[aria-expanded="true"] .rs-chev::before { transform: rotate(45deg); transition: transform var(--dur-quick) var(--ease-snap); }

/* The detail grows out of its row: grid rows 0fr → 1fr, so it opens exactly
   as tall as it is with no measured height, and the rows under it move down
   with it rather than jumping. Closing runs on the exit curve at 0.7. While
   closed it is inert (no tab stop inside) and hidden from assistive tech. */
.rs-more {
  display: grid; grid-template-rows: 0fr; background: var(--card-2); visibility: hidden;
  transition: grid-template-rows calc(var(--dur-base) * var(--dur-exit-scale)) var(--ease-exit),
              visibility 0s linear calc(var(--dur-base) * var(--dur-exit-scale));
}
.rs-row[aria-expanded="true"] + .rs-more {
  grid-template-rows: 1fr; visibility: visible;
  transition: grid-template-rows var(--dur-base) var(--ease-snap), visibility 0s;
}
.rs-more-in {
  min-height: 0; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 18px;
  padding: 0 16px 0 48px; opacity: 0; transform: translateY(-4px);
  transition: opacity calc(var(--dur-quick) * var(--dur-exit-scale)) var(--ease-exit), transform calc(var(--dur-quick) * var(--dur-exit-scale)) var(--ease-exit), padding calc(var(--dur-base) * var(--dur-exit-scale)) var(--ease-exit);
}
.rs-row[aria-expanded="true"] + .rs-more .rs-more-in {
  opacity: 1; transform: none; padding: 2px 16px 16px 48px;
  transition: opacity var(--dur-base) var(--ease-snap) 40ms, transform var(--dur-base) var(--ease-snap) 40ms, padding var(--dur-base) var(--ease-snap);
}
.rs-more-col { display: grid; gap: 3px; align-content: start; min-width: 0; }
.rs-more-h { margin: 0 0 2px; font-size: 12.5px; font-weight: 600; }
.rs-more-text { margin: 0; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.rs-more-sub { margin: 0; font-size: 12.5px; color: var(--dim); line-height: 1.45; overflow-wrap: anywhere; }
.rs-more-sub .tm-status { font-size: 12.5px; }
.rs-more-acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.rs-more-btn { margin: 10px 16px 14px; }
.rs-empty { background: var(--card); border-radius: var(--card-r); box-shadow: var(--elev-1); padding: 22px 20px; }
.rs-empty-h { margin: 0; font-weight: 500; }
.rs-empty-sub { margin: 4px 0 0; color: var(--dim); font-size: var(--t-sm); max-width: 60ch; }
.rs-empty .ghost { margin-top: 12px; }
.rs-foot { margin: 0; font-size: 12.5px; color: var(--dim); max-width: 80ch; }

/* Arrival: the cards and the first six rows rise in turn, once per visit and
   once per month chosen — never on the half-minute re-read. */
#results-view.rs-enter .rs-card { animation: td-rise var(--dur-panel) var(--ease-snap) both; }
#results-view.rs-enter .rs-card:nth-child(2) { animation-delay: 30ms; }
#results-view.rs-enter .rs-card:nth-child(3) { animation-delay: 60ms; }
#results-view.rs-enter .rs-card:nth-child(4) { animation-delay: 90ms; }
#results-view.rs-enter .rs-item,
.rs-list.rs-arrive .rs-item { animation: td-rise var(--dur-base) var(--ease-snap) both; animation-delay: calc(60ms + var(--i, 6) * 18ms); }

@container page (max-width: 820px) {
  .rs-cols { display: none; }
  .rs-row {
    grid-template-columns: minmax(0, 1fr) auto 16px; grid-template-areas: "change cost chev" "meta meta meta"; row-gap: 4px;
  }
  .rs-change { grid-area: change; }
  .rs-cost { grid-area: cost; }
  .rs-chev { grid-area: chev; }
  .rs-when, .rs-who { grid-row: 2; font-size: 12px; color: var(--dim); }
  .rs-when { grid-column: 1; padding-left: 32px; }
  .rs-who { grid-column: 1 / -1; padding-left: calc(32px + 6ch); }
  .rs-more-in, .rs-row[aria-expanded="true"] + .rs-more .rs-more-in { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .rs-row[aria-expanded="true"] + .rs-more .rs-more-in { padding: 4px 16px 16px 48px; }
  .rs-more-acts { flex-direction: row; flex-wrap: wrap; }
  /* Two lines, not one: at phone width one line left "Added 4 phrase-matc…",
     which says nothing. The approval card's sentence is the row's point. */
  .rs-title { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.3; }
  .rs-row { align-items: start; }
}

/* ---------- the Calendar: the head ------------------------------------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cal-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
#calendar-h { min-width: 7.5ch; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-step {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--text); cursor: pointer;
  transition: background var(--dur-instant) var(--ease-snap), border-color var(--dur-instant) var(--ease-snap);
}
.cal-step:hover { background: var(--card-2); }
.cal-step:active { transform: scale(.96); }
.cal-step:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.cal-switch { display: inline-flex; gap: 4px; }
.cal-legend-in { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.cal-key { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); }

/* One hue per kind, as the canvas's legend: a wash with its own ink. A
   results check is the dashed outline the canvas gives it. */
.cal-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--k-wash); box-shadow: inset 0 0 0 1px var(--k-ink); }
:is(.cal-chip, .cal-dot, .cal-key, .cal-ev)[data-kind="job"] { --k-wash: var(--denim-tint); --k-ink: var(--denim); }
:is(.cal-chip, .cal-dot, .cal-key, .cal-ev)[data-kind="change"] { --k-wash: var(--honey-tint); --k-ink: var(--honey); }
:is(.cal-chip, .cal-dot, .cal-key, .cal-ev)[data-kind="goal"] { --k-wash: var(--sage-tint); --k-ink: var(--sage); }
:is(.cal-chip, .cal-dot, .cal-key, .cal-ev)[data-kind="review"] { --k-wash: var(--plum-tint); --k-ink: var(--plum); }
:is(.cal-chip, .cal-dot, .cal-key, .cal-ev)[data-kind="report"] { --k-wash: var(--sky-tint); --k-ink: var(--sky); }
:is(.cal-chip, .cal-dot, .cal-key, .cal-ev)[data-kind="check"] { --k-wash: var(--card); --k-ink: var(--dim); }
.cal-ev[data-kind="check"] .cal-swatch, .cal-key[data-kind="check"] .cal-swatch { box-shadow: none; border: 1px dashed var(--dim); box-sizing: border-box; }

/* ---------- the Calendar: the month --------------------------------------------- */
.cal-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
@container page (max-width: 980px) { .cal-cols { grid-template-columns: minmax(0, 1fr); } }
.cal-board { position: relative; min-width: 0; }
.cal-month, .cal-agenda { background: var(--card); border-radius: var(--card-r); box-shadow: var(--elev-1); overflow: hidden; }
.cal-wd { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.cal-wd span { padding: 9px 8px; font: 500 12px/1 var(--f-body); letter-spacing: normal; text-transform: none; color: var(--dim); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
/* A day (UI/UX PR 3, 2026-11-19; calendar-view.js says what changed): 8px
   in from every edge, the number, then up to three 24px chips 4px apart.
   The height is what that holds — 8 + 24 + 4 + 3 × 24 + 2 × 4 + 8 = 124 —
   so a busy day never pushes its row taller than a quiet one. */
.cal-day {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; min-height: 124px;
  padding: 8px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: none;
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  transition: background-color var(--dur-tap) var(--ease-standard), box-shadow var(--dur-tap) var(--ease-standard);
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:nth-last-child(-n + 7) { border-bottom: 0; }
.cal-day:hover { background: var(--card-2); }
.cal-day:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; z-index: 1; }
.cal-day[aria-expanded="true"] { background: var(--card-2); box-shadow: inset 0 0 0 1.5px var(--text); }
.cal-day[data-out="true"] { background: color-mix(in srgb, var(--card-2) 45%, var(--card)); }
.cal-day[data-out="true"] .cal-n { color: var(--dim-2); }
.cal-n {
  display: inline-grid; place-items: center; align-self: flex-start; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 999px; box-sizing: border-box;
  font: 500 12.5px/1 var(--f-body); letter-spacing: normal; font-variant-numeric: tabular-nums;
}
.cal-day[data-today="true"] .cal-n { background: var(--btn-ink); color: var(--on-btn-ink); }
.cal-chips { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
/* A kind's chip: the card's own ground, a hairline, and the kind's colour as
   a 3px left edge — the colour says which kind, the words say what, and a
   cell of three chips is not three blocks of colour. It was a full wash in
   the kind's tint until 2026-11-19, and the tints at 11.5px read as a row
   of coloured noise. */
.cal-chip {
  display: flex; align-items: center; gap: 0; height: 24px; padding: 0 8px 0 10px; box-sizing: border-box; border-radius: 6px;
  background: var(--card); box-shadow: inset 3px 0 0 var(--k-ink), inset 0 0 0 1px var(--line);
  color: var(--text); font-size: 12px; line-height: 24px; font-weight: 500; white-space: nowrap; overflow: hidden;
  transition: box-shadow var(--dur-tap) var(--ease-standard);
}
.cal-chip-w { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cal-chip-n { flex: none; margin-left: 4px; color: var(--dim); font-variant-numeric: tabular-nums; }
/* A results check is due, not done: its edge is dashed, as its key is. */
.cal-chip[data-kind="check"] {
  box-shadow: inset 0 0 0 1px var(--line);
  background: repeating-linear-gradient(to bottom, var(--k-ink) 0 3px, transparent 3px 6px) left top / 3px 100% no-repeat, var(--card);
}
.cal-day:hover .cal-chip { box-shadow: inset 3px 0 0 var(--k-ink), inset 0 0 0 1px var(--line-2); }
.cal-day:hover .cal-chip[data-kind="check"] { box-shadow: inset 0 0 0 1px var(--line-2); }
.cal-more { font-size: 12px; line-height: 16px; color: var(--dim); padding-left: 10px; }
/* A narrow day (a 1024px window, or the month beside an open chat): the
   chip's padding tightens and the count drops its ×, so "Check-ins 2" fits
   where "Check-ins ×2" was cut to "Check-… ×2" (measured at 1024, 100px
   cells). The 8px inset from the cell's edge stays. */
.cal-day { container: calday / inline-size; }
@container calday (max-width: 120px) {
  .cal-chip { padding: 0 6px 0 8px; font-size: 11.5px; }
  .cal-chip-x { display: none; }
  .cal-chip-n { margin-left: auto; padding-left: 4px; }
  .cal-more { padding-left: 8px; }
}

/* A day's list grows from the day pressed (its transform-origin is set to
   that day by calendar-view.js) and leaves faster than it came. */
.cal-pop {
  position: absolute; z-index: 20; width: 320px; max-width: calc(100vw - 32px); max-height: min(380px, 70vh); overflow: auto;
  background: var(--card); border-radius: 14px; box-shadow: var(--elev-3); outline: none;
  transform-origin: var(--pop-origin, 50% 0);
}
.cal-pop.is-entering { animation: cal-pop-in var(--dur-quick) var(--ease-snap) both; }
.cal-pop.is-leaving { animation: cal-pop-out calc(var(--dur-quick) * var(--dur-exit-scale)) var(--ease-exit) both; }
@keyframes cal-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.96); } }
@keyframes cal-pop-out { to { opacity: 0; transform: translateY(-2px) scale(.97); } }
.cal-pop-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 6px 16px; background: var(--card); }
.cal-pop-h { margin: 0; font-size: 14px; font-weight: 600; }
.cal-pop-x {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 999px;
  background: none; color: var(--dim); cursor: pointer; transition: background var(--dur-instant) var(--ease-snap);
}
.cal-pop-x:hover { background: var(--card-2); color: var(--text); }
.cal-pop-x:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 0; }
.cal-pop-body { padding: 0 8px 10px; }
.cal-pop .cal-ev { animation: td-rise var(--dur-base) var(--ease-snap) both; animation-delay: calc(var(--i, 6) * 18ms); }
.cal-pop .cal-empty { padding: 4px 8px 6px; }

/* An event: a swatch, its words, and when. A button where it opens something. */
.cal-evs { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cal-ev-open {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: start; column-gap: 10px; width: 100%;
  padding: 8px; border: 0; border-radius: var(--card-r-in); background: none; font: inherit; color: var(--text); text-align: left;
}
.cal-ev-open .cal-swatch { margin-top: 4px; }
button.cal-ev-open { cursor: pointer; transition: background var(--dur-instant) var(--ease-snap); }
button.cal-ev-open:hover { background: var(--card-2); }
button.cal-ev-open:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.cal-ev-words { display: grid; gap: 1px; min-width: 0; }
.cal-ev-title { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.cal-ev-sub { font-size: 12px; color: var(--dim); overflow-wrap: anywhere; }
.cal-ev-time { font: 500 12px/1.4 var(--f-body); letter-spacing: normal; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cal-empty { margin: 0; color: var(--dim); font-size: var(--t-sm); }

/* The list view: a day per section. */
.cal-agenda { padding: 6px 8px 10px; }
.cal-agenda > .cal-empty { padding: 16px 10px; }
.cal-agenda-day + .cal-agenda-day { border-top: 1px solid var(--line); }
.cal-agenda-day { padding: 8px 0 4px; }
.cal-agenda-h { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 8px; font-size: 12.5px; font-weight: 600; color: var(--dim); }
.cal-agenda-today { font: 500 12px/1 var(--f-body); letter-spacing: normal; text-transform: none; padding: 3px 6px; border-radius: 999px; background: var(--btn-ink); color: var(--on-btn-ink); }

/* The side. */
.cal-side { display: grid; gap: 12px; min-width: 0; }
.cal-side-in { display: grid; gap: 12px; }
.cal-card { background: var(--card); border-radius: var(--card-r); box-shadow: var(--elev-1); padding: 12px 10px 10px; }
.cal-card-h { margin: 0 6px 6px; font-size: var(--t-md); font-weight: 600; }
.cal-card-note { margin: 0 6px 4px; font-size: 12.5px; color: var(--dim); line-height: 1.45; }
.cal-sum { margin: 0 6px; display: grid; }
.cal-sum-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.cal-sum-row:first-child { border-top: 0; }
.cal-sum dt { font-size: var(--t-sm); color: var(--dim); }
.cal-sum dd { margin: 0; font-size: var(--t-sm); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Arrival: the month (or the list) fades up 4px on arrival and on a month
   change; the days do not each animate — 35 moving boxes is noise. */
.cal-board-in.cal-arrive { animation: td-rise var(--dur-base) var(--ease-snap) both; }
.cal-board-in.cal-arrive .cal-agenda-day { animation: td-rise var(--dur-base) var(--ease-snap) both; animation-delay: calc(var(--i, 6) * 18ms); }

/* ---------- Today: the figures ---------------------------------------------- */
.td-stats { margin-top: 18px; }
.td-stats-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
/* "At a glance": secondary words, as written (2026-11-17; was spaced mono
   capitals, the one eyebrow on the page that shouted). */
.td-stats-h { margin: 0; font: 500 13px/1.2 var(--f-body); letter-spacing: normal; text-transform: none; color: var(--dim); }
.td-range { display: flex; gap: 6px; }
.td-stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
/* Three across by the row's own width, not only on a phone (flow finding,
   1024, 2026-10-21). With the chat panel open at 1024 Today's column is about
   460px, under the 530 three 170px cards need, and they fell two and an
   orphan — the phone's rule below fixed exactly this, but only under its
   media query, which a narrow column in a wide window never matches. The
   same compact three, wherever the figures have less room than three full
   cards. */
.td-stats { container: tdstats / inline-size; }
@container tdstats (max-width: 540px) {
  .td-stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .td-stat { padding: 10px 12px; }
  .td-stat-num { font-size: 20px; }
  .td-stat-sub { white-space: normal; font-size: 11.5px; line-height: 1.3; }
}
.td-stat {
  display: grid; gap: 2px; align-content: start; min-width: 0; padding: 12px 14px; border: 0; border-radius: var(--card-r);
  background: var(--card); box-shadow: var(--elev-1); font: inherit; color: var(--text); text-align: left;
}
button.td-stat { cursor: pointer; transition: box-shadow var(--dur-quick) var(--ease-snap), transform var(--dur-instant) var(--ease-snap); }
button.td-stat:hover { box-shadow: var(--elev-2); }
button.td-stat:active { transform: scale(.99); }
button.td-stat:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.td-stat-label { font-size: 12.5px; color: var(--dim); }
.td-stat-num { font-size: 26px; font-weight: 600; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
/* Wraps rather than ending in "…": at three across beside an open chat,
   "to the store or a repository in 7 days" was cut after "in" (desktop QA,
   2026-10-14), and the half that went was the period it counts. */
.td-stat-sub { font-size: 12.5px; line-height: 1.35; color: var(--dim); overflow-wrap: anywhere; }
/* A changed figure fades in, once; a figure never rolls or springs. */
.td-stats-row .td-stat-num { animation: td-fade var(--dur-base) var(--ease-snap) both; }
#today-view.td-enter .td-stats { animation: td-rise var(--dur-panel) var(--ease-snap) both; }

/* ---------- Today: the first run ---------------------------------------------- */
.td-first { margin-top: 18px; }
.fr-in { background: var(--card); border-radius: var(--card-r); box-shadow: var(--elev-1); padding: 18px 20px 20px; }
.fr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.fr-words { display: grid; gap: 4px; min-width: 0; }
.fr-h { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.fr-sub { margin: 0; font-size: 13.5px; color: var(--dim); max-width: 60ch; }
.fr-later { flex: none; }
/* 180px, so the three steps stay three across in the ~640px a page has beside
   the open chat at 1440; at 220px they went two and an orphan on a row of its
   own (desktop QA, 2026-10-14). Narrower than three fit, they still stack. */
.fr-track { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 12px; counter-reset: none; }
.fr-step {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 14px 16px 16px; border-radius: var(--card-r-in);
  border: 1px solid var(--line); background: color-mix(in srgb, var(--card-2) 55%, var(--card));
  animation: fr-in var(--dur-panel) var(--ease-snap) both; animation-delay: calc(60ms + var(--i, 0) * 40ms);
}
@keyframes fr-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.fr-step-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fr-n {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; flex: none;
  background: var(--btn-ink); color: var(--on-btn-ink); font: 600 12px/1 var(--f-body); font-variant-numeric: tabular-nums;
}
.fr-state { font-size: 12px; color: var(--dim); text-align: right; }
.fr-title { margin: 4px 0 0; font-size: 15px; font-weight: 600; }
.fr-text { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.45; flex: 1; }
.ghost.fr-go { align-self: flex-start; margin-top: 6px; background: var(--btn-ink); border-color: var(--btn-ink); color: var(--on-btn-ink); }
.ghost.fr-go:hover:not(:disabled) { background: color-mix(in srgb, var(--btn-ink) 86%, var(--paper)); border-color: transparent; color: var(--on-btn-ink); }
.ghost.fr-go:active:not(:disabled) { transform: scale(.98); }
/* "Not now" folds it away on the exit curve, faster than it came. */
.td-first.fr-leaving { overflow: hidden; animation: fr-fold calc(var(--dur-panel) * var(--dur-exit-scale)) var(--ease-exit) both; }
@keyframes fr-fold {
  from { height: var(--fr-h); opacity: 1; }
  to { height: 0; margin-top: 0; opacity: 0; transform: translateY(-4px); }
}

/* ---------- phones ------------------------------------------------------------------ */
@media (max-width: 720px) {
  #results-view, #calendar-view { padding: 16px 16px 28px; }
  .rs-hero { flex-basis: 100%; }
  .rs-hero .rs-num { font-size: 28px; }
  .rs-card { flex-basis: calc(50% - 5px); }
  /* After .rs-card, which the hero also is: the figure needs the full width,
     or "about $0.18 per change" breaks over three lines. */
  .rs-card.rs-hero { flex-basis: 100%; }
  .rs-more-in, .rs-row[aria-expanded="true"] + .rs-more .rs-more-in { padding-left: 16px; }
  .cal-title { gap: 8px; }
  .cal-wd span { padding: 8px 4px; font-size: 10px; letter-spacing: 0; text-align: center; }
  /* From 641 to 720px with a mouse the chips stay (calendar-view.js
     `PHONE_CAL`), in the narrow cell's tighter chip (`@container calday`
     above): a cell is about 95px wide there. Each event was a 5px bar with
     no words at this width until 2026-11-19. */
  .cal-day { min-height: 112px; padding: 6px; }
  /* Above the tab bar and its raised Ask button, not under them: #main is a
     stacking context, so no z-index here beats the bar, and at bottom: 8px the
     sheet's last rows sat behind it (390x844, 2026-10-12). 96px is the
     clearance the celebration toast measured for the same cluster. */
  .cal-pop {
    position: fixed; left: 8px; right: 8px; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); top: auto; width: auto; max-width: none;
    max-height: calc(100dvh - 180px); border-radius: 18px; transform-origin: 50% 100%;
  }
  .cal-pop.is-entering { animation: cal-sheet-in var(--dur-panel) var(--ease-snap) both; }
  .cal-pop.is-leaving { animation: cal-sheet-out calc(var(--dur-panel) * var(--dur-exit-scale)) var(--ease-exit) both; }
  @keyframes cal-sheet-in { from { opacity: 0; transform: translateY(16px); } }
  @keyframes cal-sheet-out { to { opacity: 0; transform: translateY(12px); } }
  .fr-in { padding: 16px; }
  .fr-head { flex-wrap: wrap; }
  /* Three across, not two and an orphan: the three figures are read together. */
  .td-stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .td-stat { padding: 10px 12px; }
  .td-stat-num { font-size: 20px; }
  .td-stat-sub { white-space: normal; font-size: 11.5px; line-height: 1.3; }
}

/* ---------- the Calendar on a phone: dots, and the day under the month -----------
   The same query as calendar-view.js `PHONE_CAL`, so the cells sized for
   dots here are exactly the cells drawn with dots there. A cell is the
   number and up to three 6px dots under it, centred, at least 52px tall
   (and about 51px wide at 390): a thumb's 44px each way with room to spare.
   Today is the filled circle it is on a desk; the chosen day is a ring, and
   today chosen is both, the ring standing off the fill. */
@media (max-width: 640px), (pointer: coarse) and (max-width: 820px) {
  .cal-month[data-shape="dots"] .cal-day {
    min-height: 52px; padding: 6px 0 8px; gap: 5px; align-items: center; justify-content: flex-start;
  }
  .cal-month[data-shape="dots"] .cal-n { align-self: center; min-width: 30px; height: 30px; padding: 0 6px; font-size: 15px; }
  .cal-month[data-shape="dots"] .cal-day:hover { background: none; }
  .cal-month[data-shape="dots"] .cal-day[aria-expanded="true"] { background: none; box-shadow: none; }
  .cal-month[data-shape="dots"] .cal-day[aria-expanded="true"] .cal-n { box-shadow: inset 0 0 0 1.5px var(--text); font-weight: 600; }
  .cal-month[data-shape="dots"] .cal-day[aria-expanded="true"][data-today="true"] .cal-n { box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px var(--btn-ink); }
  .cal-month[data-shape="dots"] .cal-day:focus-visible { outline-offset: -3px; border-radius: 10px; }
  .cal-dots { display: flex; justify-content: center; gap: 4px; height: 6px; }
  .cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--k-ink); }
  .cal-dot[data-kind="check"] { background: none; box-shadow: inset 0 0 0 1.25px var(--k-ink); }
  /* The chosen day's list: a card of its own under the month, its rows the
     popover's rows at a thumb's height. */
  .cal-dayview { margin-top: 12px; padding: 12px 8px 8px; background: var(--card); border-radius: var(--card-r); box-shadow: var(--elev-1); }
  .cal-dayview-h { display: flex; align-items: center; gap: 8px; margin: 0 8px 6px; font-size: 15px; font-weight: 600; }
  .cal-dayview .cal-ev-open { min-height: 44px; box-sizing: border-box; }
  .cal-dayview .cal-empty { padding: 6px 8px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  #results-view.rs-enter .rs-card, #results-view.rs-enter .rs-item, .rs-list.rs-arrive .rs-item,
  .cal-board-in.cal-arrive, .cal-board-in.cal-arrive .cal-agenda-day, .cal-pop .cal-ev,
  .fr-step, #today-view.td-enter .td-stats, .td-stats-row .td-stat-num {
    animation: td-fade 80ms linear both; animation-delay: 0s;
  }
  .cal-pop.is-entering { animation: td-fade 80ms linear both; }
  .cal-pop.is-leaving { animation: cal-fade-out 80ms linear both; }
  @keyframes cal-fade-out { to { opacity: 0; } }
  .td-first.fr-leaving { animation: none; }
  .rs-more, .rs-row[aria-expanded="true"] + .rs-more,
  .rs-more-in, .rs-row[aria-expanded="true"] + .rs-more .rs-more-in { transition: opacity 80ms linear, visibility 0s; transform: none; }
  .rs-chev::before, .rs-row[aria-expanded="true"] .rs-chev::before { transition: none; }
  .rs-filt, .td-range-b, .cal-seg, .cal-step, .cal-day, .cal-chip, .cal-ev-open, .cal-pop-x, .rs-row, button.td-stat { transition: none; }
}

/* ---------- Results: what each change earned (seo outcome checks) ---------------- */
.oc-sec { flex-basis: 100%; margin-bottom: 14px; }
.oc-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--dim); }
.oc-problem { margin: 6px 0 0; font-size: 13px; }
.oc-list { list-style: none; margin: 10px 0 0; padding: 0; }
.oc-item { border-top: 1px solid var(--line); }
.oc-row {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1.4fr); column-gap: 14px; align-items: center;
  padding: 10px 4px; border: 0; background: none; font: inherit; font-size: var(--t-sm); color: var(--text); text-align: left; cursor: pointer;
}
.oc-row:hover, .oc-row[aria-expanded="true"] { background: var(--card-2); }
.oc-row:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.oc-words, .oc-lines { display: grid; gap: 2px; min-width: 0; }
.oc-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-when { font-size: 12.5px; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.oc-line { font-size: 12.5px; }
.oc-more { padding: 10px 4px 14px; display: grid; gap: 10px; }
.oc-url { font-size: 12.5px; overflow-wrap: anywhere; }
.oc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.oc-table th, .oc-table td { text-align: left; padding: 4px 8px 4px 0; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.oc-h { margin: 0; font-size: 13px; }
.oc-verdict { margin: 2px 0 6px; }
.oc-drift, .oc-trace { margin: 0; padding-left: 18px; font-size: 12.5px; }
.oc-sev { font: 500 12px/1 var(--f-body); letter-spacing: normal; text-transform: none; margin-right: 6px; color: var(--dim); }
@media (max-width: 720px) {
  /* The same row, stacked: page, then date, then the two verdict lines. */
  .oc-row { grid-template-columns: minmax(0, 1fr); row-gap: 4px; }
  .oc-table th, .oc-table td { padding-right: 4px; }
}

/* ---------- nothing floating over the month (UI/UX PR 3, 2026-11-19) ----------
   The floating Ask Scout pill sat over the grid's lower right — over the 15th,
   measured on the live app at 1440 — and a press there opened Ask Scout
   rather than the day. On the Calendar it is not drawn; ⌘J still opens Ask
   Scout's card, as it does beside the open side panel (beta-shell.css). */
@media (min-width: 821px) {
  #app.view-calendar #companion[data-shape="pill"] { display: none; }
}
