.row-menu {
  flex: 0 0 auto;
}

/* The day head's weather link opens the hourly forecast modal: it ends in the
   kit's window mark. */
.day-column-weather-dialog::after {
  content: "";
  flex: none;
  width: 0.875em;
  height: 0.875em;
  margin-inline-start: var(--space-1);
  background: currentColor;
  -webkit-mask: var(--icon-dialog) center / contain no-repeat;
  mask: var(--icon-dialog) center / contain no-repeat;
}

.day-note {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.day-frame {
  display: block;
  scroll-margin-top: 3rem;
}

.day {
  container-type: inline-size;
  /* The cycles menu's panel spans this box (UI::Menu align: :fill). */
  position: relative;
  padding: var(--space-3);
  background: var(--surface);
  border: var(--line-width) solid var(--line);
  border-radius: var(--radius-md);
}

.day-today {
  box-shadow: 0 0 0 2px var(--accent);
}

/* The Calendar week's column: the planner's tinted day bar
   (.day-column-bar) bleeds to the column's edges, so it reads this box's
   padding and radius. */
.day-calendar {
  --day-column-pad-y: var(--space-3);
  --day-column-pad-x: var(--space-3);
  --day-column-radius: var(--radius-md);
}

.day-calendar-selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 1px var(--primary-color);
}

.day-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
  align-content: start;
}

.day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  min-width: 0;
}

.day-title {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-tight);
}

.day-title-link {
  color: inherit;
  text-decoration: none;
}

.day-title-link:hover {
  text-decoration: underline;
}

/* The day head's chips are inline-block, so no flex gap sets a chip's window
   mark (.chip-dialog::after) apart from its words. */
.day-head-chip::after {
  margin-inline-start: var(--space-1);
}

.day-head-chip {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5rem;
  vertical-align: middle;
}

.day-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
  align-content: start;
  min-width: 0;
}

.day-grid {
  display: grid;
  gap: var(--space-3);
}

/* The weekly planner's board (Views::WeeklyPlanners::DayBoard): the week
   as lanes, then the selected day's detail under them. */
.planner-week {
  container-type: inline-size;
}

/* The week brief over the board (Views::WeeklyPlanners::WeekBrief): no box,
   one row that wraps: where the week sits (the cycle and its week), then the
   guidance disclosure's summary. An open disclosure takes the full width
   under the line. */
.planner-brief {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--space-4);
  row-gap: var(--space-1);
}

.week-brief-guidance[open] {
  flex-basis: 100%;
}

.planner-strip {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-sunken);
}

/* The week as lanes. Rows run Monday to Sunday, one per lane; the first
   column heads each lane (Views::WeeklyPlanners::LaneHeads) and every day
   is one column spanning all the rows (DayColumn), its cells on the rows
   the seven share (subgrid), so the same thing sits at the same height on
   every day. The row count is the grid's --planner-lane-rows: six lanes
   plus one per cycle row. Too narrow for all seven days, the lanes scroll
   sideways under their heads, pinned at the left. */
/* position: the lanes hold what is placed inside them (a label only a
   screen reader reads, a tile's menu), so it scrolls with the lanes and
   never widens the page. */
.planner-lanes {
  position: relative;
  overflow-x: auto;
  border: var(--line-width) solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

/* The grid is as wide as its tracks, never as narrow as the box it scrolls
   in: the lane heads pin against the grid's own box, so a grid the width of
   the scroller would let them go a day or two into a swipe. */
.planner-lanes-grid {
  display: grid;
  grid-template-columns: minmax(10rem, 15rem) repeat(7, minmax(8.5rem, 1fr));
  grid-template-rows: repeat(var(--planner-lane-rows), auto);
  min-width: calc(10rem + 7 * 8.5rem);
}

.planner-lane-heads {
  grid-column: 1;
  grid-row: 1 / span var(--planner-lane-rows);
  display: grid;
  grid-template-rows: subgrid;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface-sunken);
  border-inline-end: var(--line-width) solid var(--line);
}

.planner-lane-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border-top: var(--line-width) solid var(--line);
}

.planner-lane-head-corner {
  justify-content: center;
  border-top: 0;
  background: var(--stratum-head);
}

/* A lane's name beside the button that hides or shows the lane. */
.planner-lane-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.planner-lane-toggle {
  margin: 0;
}

/* The muscles lane's choice of reading (MuscleSeriesSwitch). */
.planner-lane-series {
  margin: 0;
}

/* A lane's full view or its one line, and each of the muscles lane's
   readings: the page carries them all and shows one (week_board_controller.js),
   so the part adds no box of its own. */
.planner-lane-part {
  display: contents;
}

/* display outranks the browser's own [hidden] rule. */
.planner-lane-part[hidden],
.planner-lane-cell[hidden],
.planner-lane-head[hidden] {
  display: none;
}

/* A hidden lane's one line for the day (DayColumn's summaries). */
.planner-lane-summary {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.planner-lane-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
}

.planner-lane-note {
  margin: 0;
  font-size: var(--text-xs);
  line-height: var(--leading);
  color: var(--ink-muted);
}

/* What a phone's lane head leaves out: the week's headlines one by one
   (WeekHeadlines folds them into one chip there) and the muscles lane's
   note. Both come back where the head has the width for them. */
.planner-headlines {
  display: none;
}

.planner-lane-note-wide {
  display: none;
}

/* How a session's state is drawn: by its outline, never its colour. */
.planner-lane-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.planner-lane-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.planner-lane-swatch {
  width: 0.875rem;
  height: 0.625rem;
  border-radius: var(--radius-sm);
}

.planner-lane-swatch-scheduled {
  background: var(--stratum-head);
  box-shadow: inset 0 0 0 1px var(--line);
}

.planner-lane-swatch-draft {
  box-shadow: inset 0 0 0 1px var(--ink-muted);
}

.planner-lane-swatch-planned {
  border: 1px dashed var(--ink-muted);
}

/* One day across the lanes. The column hands its rows to its cells; a
   cell a day has nothing for is drawn empty so the rows stay shared. */
.planner-day-column {
  --day-column-pad-x: var(--space-2);
  --day-column-pad-y: var(--space-1);
  --day-column-radius: 2px;
  grid-row: 1 / span var(--planner-lane-rows);
  display: grid;
  grid-template-rows: subgrid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  background: var(--surface);
  border-inline-start: var(--line-width) solid var(--line);
  /* A jump from the day strip lands the day clear of the strip pinned
     above it and of the lane heads pinned beside it. */
  scroll-margin-top: 3rem;
  scroll-margin-inline-start: 15rem;
}

/* The selected day, the one open under the lanes, outlined down every
   lane. */
.day-column-expanded {
  background: var(--accent-soft);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.planner-lane-cell {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-2);
  border-top: var(--line-width) solid var(--line);
}

/* The day's head bar bleeds to the cell's edges (DayColumnHead cancels
   the padding with the column's --day-column-pad-*). */
.planner-lane-cell-head {
  padding: var(--day-column-pad-y) var(--day-column-pad-x);
  border-top: 0;
  background: var(--stratum-head);
}

.planner-lane-cell-actions {
  justify-content: end;
}

/* How a day answers a cycle with no session of it: planned movements, a
   template, a stimulus plan. */
.planner-lane-via {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

/* The plan calendar's weeks as lanes (Views::PlanCalendars::Show
   render_weeks): one lanes grid per week, stacked, each with the muscle
   band under it. */
.lane-weeks {
  display: grid;
  gap: var(--space-3);
}

.lane-week {
  display: grid;
  gap: var(--space-1);
  scroll-margin-top: var(--space-6);
}

/* A day of a week row outside the span the page is about: kept so the
   week reads whole, stepped back so the span stands out. */
.planner-day-column-outside {
  background: var(--surface-sunken);
  opacity: 0.6;
}

/* A day nothing can be moved into or out of (a released day in Arrange). */
.planner-day-column-locked {
  background: var(--surface-sunken);
}

/* Days a traced row or the month's highlight misses step back
   (month_score_controller.js). */
.planner-day-column[data-score-match="false"] {
  opacity: 0.3;
  transition: opacity 160ms ease-out;
}

.planner-day-column[data-lens-match="false"] {
  opacity: 0.3;
  transition: opacity 160ms ease-out;
}

/* Wide enough for all seven days, the lanes stop scrolling sideways, so
   the days' heads and the switch above the lane heads can stay pinned at
   the top of the screen while the lanes scroll under them. */
/* On a phone the heads take less of the width the days scroll in, and a
   day is 10rem whatever it holds: wide enough for a session's name and
   stimulus to read in whole words. */
@container (max-width: 47.99rem) {
  .planner-lanes-grid {
    grid-template-columns: 8rem repeat(7, 10rem);
    min-width: calc(8rem + 7 * 10rem);
  }

  .planner-day-column {
    scroll-margin-inline-start: 8rem;
  }

  .planner-lane-head {
    padding: var(--space-2);
  }
}

@container (min-width: 48rem) {
  .planner-headlines {
    display: block;
  }

  .planner-headlines-fold {
    display: none;
  }

  .planner-lane-note-wide {
    display: block;
  }
}

@container (min-width: 72rem) {
  .planner-lanes {
    overflow: visible;
  }

  .planner-lane-cell-head,
  .planner-lane-head-corner {
    position: sticky;
    top: 0;
    z-index: 1;
  }
}

/* The way to add to a day where its lane is read (DayColumn): a quiet
   button at the foot of the Sessions and Movements cells, under whatever
   the cell holds, whose popover carries the open day's tools (a stimulus:
   StimulusPalette; a movement: the Select Elements panel). */
.planner-lane-add {
  margin-top: auto;
  align-self: flex-start;
}

/* Opens on whichever side of the button has more room, no taller than the
   room on that side (100% is the anchored area), and scrolls inside rather
   than running past the window, which a top-layer panel cannot scroll to. */
.planner-lane-add-panel {
  width: min(24rem, calc(100vw - 2 * var(--space-2)));
  max-height: min(70vh, 100%);
  padding: var(--space-3);
  position-try-order: most-block-size;
}

/* A stimulus pill in the Sessions popover (StimulusPalette): a tap adds it. */
.planner-stimulus-pill {
  min-height: var(--tap-dense);
  cursor: pointer;
  user-select: none;
}

.planner-lane-add-panel-wide {
  width: min(44rem, calc(100vw - 2 * var(--space-2)));
}

/* The day in order, one card each (Components::Calendar::DaySequenceList),
   on the planner's column and open day and each day of the plan calendar. */
.planner-day-sessions {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.planner-day-sequence-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* One card of the day and its ⋯ menu beside it, as a tile whose outline
   says its state, so its colour is left to its stimulus: a scheduled
   workout solid on the head's ground, a draft outlined and open, a planned
   block a dashed outline (the lanes' legend, LaneHeads). */
.planner-day-sequence-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-1);
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

/* A tile with a ⋯: the menu sits in the tile's top corner beside the name,
   so everything under the name has the tile's whole width. */
.planner-day-sequence-item-menu {
  --session-tile-menu-room: var(--tap-dense);
  position: relative;
  grid-template-columns: minmax(0, 1fr);
}

.planner-day-sequence-item-scheduled {
  background: var(--stratum-head);
  box-shadow: inset 0 0 0 1px var(--line);
}

.planner-day-sequence-item-draft {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ink-muted);
}

.planner-day-sequence-item-planned {
  background: var(--surface);
  border: 1px dashed var(--ink-muted);
}

/* A tile the month's filter or highlight leaves out steps back whole, its
   ground with its card (plan_calendar_controller.js,
   month_score_controller.js), the same as a card off a tile. */
.planner-day-sequence-item[data-filtered="out"] {
  opacity: 0.25;
}

.planner-day-sequence-item[data-lens-match="false"] {
  opacity: 0.35;
  transition: opacity 160ms ease-out;
}

.day-card-drop-target {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

/* A warning chip's popover in the column's warnings lane
   (Views::WeeklyPlanners::DayWarningChips): what the chip means, and for a
   count, the warnings under their kind's heading. The panel is its own
   container, so the kinds' fact list reads by the panel's width and puts
   each heading over its warnings, which then take the whole width. */
.planner-warning-panel {
  container-type: inline-size;
  width: calc(100vw - 2 * var(--space-2));
  padding: var(--space-2) var(--space-3);
}

/* One warning with the steps that answer it, held together and set apart
   from the next. */
.planner-warning-item {
  display: grid;
  gap: var(--space-2);
}

.planner-warning-items {
  display: grid;
  gap: var(--space-3);
}

.planner-warning-detail {
  margin: 0;
  font-size: var(--text-sm);
}

.planner-warning-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* One group of tools: the stimulus palette, the muscle focus, the
   movements. */
.planner-open-day-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.planner-open-day-hint {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

@container (min-width: 48rem) {
  .planner-strip {
    display: none;
  }
}

/* A day's strata under its head bar (Components::DayStrata), darkest to
   lightest: the cycles band, the alerts on the host's surface with no
   band, then the workouts. A band bleeds out of its host's padding to the
   host's edges; the host sets --day-band-bleed to its own side padding. */
.day-strata {
  display: grid;
  /* A host that lays its days on shared rows (the weekly planner's board)
     places the strata on them through these properties; anywhere else
     they fall back to a plain stack. */
  grid-row: var(--day-strata-row, auto);
  grid-template-rows: var(--day-strata-rows, none);
  /* One track that may shrink below its content's widest line, so a long
     button or chip wraps or clips inside a narrow column (the planner's
     seven across) instead of widening the strata past it. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--day-strata-gap, var(--space-1));
}

.day-band {
  display: var(--day-workouts-display, block);
  grid-row: var(--day-workouts-row, auto);
  grid-column: var(--day-strata-column, auto);
  grid-template-rows: var(--day-workouts-rows, none);
  margin: 0 calc(-1 * var(--day-band-bleed, var(--space-2)));
  padding: var(--day-workouts-pad, var(--space-1)) var(--day-band-bleed, var(--space-2));
}

.day-band-cycles {
  /* The box a cycle row's "N cycles" menu spans (UI::Menu align: :fill
     reads the trigger's nearest positioned ancestor): the day's full
     width, on every host, not whatever positioned box lies further out. */
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  /* Chips sit at the top of a band a shared row made taller. */
  align-content: flex-start;
  gap: var(--space-1);
  grid-row: var(--day-cycles-row, auto);
  padding: var(--space-1) var(--day-band-bleed, var(--space-2));
  background: var(--stratum-cycles);
}

.day-alerts {
  /* On shared rows the alerts keep a row of their own. */
  grid-row: var(--day-alerts-row, auto);
  grid-column: var(--day-strata-column, auto);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  /* What the slot holds (the planner's chip list, the builder's readings)
     keeps its own height at the top of a row another day made taller. */
  align-content: flex-start;
  gap: var(--space-1);
}

.day-strip {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-sunken);
}

@container (min-width: 36rem) {
  .day-layout {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  }

  .day-head {
    grid-column: 1 / -1;
  }
}

/* Off a phone the warning panel hangs from its chip at a reading width. */
@media (min-width: 40rem) {
  .planner-warning-panel {
    width: 20rem;
  }
}

@media (min-width: 64rem) {
  .day-grid {
    grid-auto-flow: column;
    grid-auto-columns: minmax(11rem, 1fr);
    align-items: start;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .day-strip {
    display: none;
  }
}

/* A day's status (Components::DayStatus): in progress, finished, released.
   The tone is the chip's (caution, good, accent); this adds the outline,
   dashed while the day is still open, and the weight. The control is the
   same pill with a select in it. */
.day-status {
  margin: 0;
  border: var(--line-width) solid currentColor;
  font-weight: 600;
}

.day-status-in_progress {
  border-style: dashed;
}

.day-status-mark {
  font-size: 0.85em;
  line-height: 1;
}

.day-status-control {
  overflow: visible;
  padding-inline-end: var(--space-1);
}

/* The select takes the pill's colors, so its open list reads in them too;
   the pill draws the border and the focus ring. */
.day-status-select {
  min-height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background-color: inherit;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* The status as a menu beside the planner's day head (DayStatus with
   menu: true, DayColumnHead status:): the mark is the trigger, each state
   in the menu is its pill and what it means, the day's own one current. */
.day-column-status {
  display: flex;
  align-items: center;
  padding-inline-end: var(--space-1);
}

/* A bar with chips after its head (DayColumnHead holidays:, tags:): the
   head keeps to its contents so they sit beside the date, and wrap to a
   line of their own in a narrow column. */
.calendar-cycle-row-stacked {
  flex-direction: column;
  align-items: stretch;
}

.day-column-bar-tagged {
  --day-column-head-grow: 0 1 auto;
  --day-column-head-pad-end: 0;
}

.day-column-head-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  padding: 0 var(--space-1) 0 var(--day-column-pad-x);
}

/* A day's own controls at the head bar's end (DayColumnHead actions:),
   end-aligned even when they wrap to a line of their own. */
.day-column-head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-inline-start: auto;
  padding: var(--space-1) var(--day-column-pad-x);
}

/* The mark is small in a day's head; its hit area is a finger's (the
   ::after reaches past the chip without moving anything). */
.day-status-trigger {
  position: relative;
  overflow: visible;
  cursor: pointer;
  font: inherit;
}

.day-status-trigger::after {
  content: "";
  position: absolute;
  inset: -0.375rem;
}

.day-status-choice-form {
  display: contents;
}

.day-status-choice {
  display: grid;
  gap: var(--space-1);
  justify-items: start;
  white-space: normal;
}

.day-status-choice-current {
  background: var(--surface-sunken);
  cursor: default;
}

.day-status-choice-hint {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.day-status-select:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* The athlete's workout card (Components::AthleteWorkoutCard) holds its
   workout text in a code block, which pads its text by --space-2. The block
   starts that much inside the card's 1rem, so the text lines up with the
   name above and the notes below. */
.athlete-workout-text {
  padding: var(--space-2);
}

/* The card's notes (Components::NoteFacts), under a rule, set in line with
   the card's name. */
.athlete-workout-notes {
  padding: var(--space-3) var(--space-4);
  border-top: var(--line-width) solid var(--line);
}
