@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@layer cinder.components {
  /* ========================================
 * STACKED LIST ITEM
 * ======================================== */

  .cinder-stacked-list-item {
    display: block;
    /* The row's anchor stretches over it (see the title link), so the row is the containing block. */
    position: relative;
    container-type: inline-size;
    container-name: cinder-stacked-list-item;
    padding: var(--cinder-space-3) var(--cinder-space-4);
    /* 0 by default; 44px under a coarse pointer (foundation.css). */
    min-block-size: var(--cinder-list-row-min-height);
  }

  .cinder-stacked-list-item[data-cinder-density='condensed'] {
    padding: var(--cinder-space-2) var(--cinder-space-3);
  }

  .cinder-stacked-list-item__layout {
    /* The line height of the title's first line, which a leading control centres itself on. */
    --_cinder-first-line: calc(var(--cinder-text-sm) * var(--cinder-leading-snug));

    display: grid;
    align-items: center;
    column-gap: var(--cinder-space-3);
    row-gap: var(--cinder-space-2);
    grid-template-columns: 1fr;
    grid-template-areas: 'body';
  }

  /* Beside a ListDetail's Hide handle, which floats over the rows at the divider, the row keeps its
     text that far from its end (`--_cinder-list-detail-handle-inset`); unset, there is no inset. */
  .cinder-stacked-list-item > .cinder-stacked-list-item__layout {
    padding-inline-end: var(--_cinder-list-detail-handle-inset, 0px);
  }

  .cinder-stacked-list-item--has-leading .cinder-stacked-list-item__layout {
    grid-template-columns: auto 1fr;
    grid-template-areas: 'leading body';
  }

  .cinder-stacked-list-item--has-leading .cinder-stacked-list-item__leading {
    align-self: start;
    /* A checkbox that leads the row sits beside the first line of the title, not the row's top
       edge or its middle (COR-2360): Checkbox offsets its box by half of what this line has over
       the box. */
    --_cinder-checkbox-line: var(--_cinder-first-line);
  }

  /* A block-level field, so the leading cell's line box adds no strut above or below the box. */
  .cinder-stacked-list-item--has-leading
    .cinder-stacked-list-item__leading
    > .cinder-checkbox-field {
    display: flex;
  }

  .cinder-stacked-list-item--has-leading .cinder-stacked-list-item__body {
    align-self: start;
  }

  .cinder-stacked-list-item--has-trailing .cinder-stacked-list-item__layout {
    grid-template-columns: 1fr auto;
    grid-template-areas: 'body trailing';
  }

  .cinder-stacked-list-item--has-leading.cinder-stacked-list-item--has-trailing
    .cinder-stacked-list-item__layout {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: 'leading body trailing';
  }

  .cinder-stacked-list-item__leading {
    grid-area: leading;
  }

  .cinder-stacked-list-item__body {
    grid-area: body;
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1);
  }

  /*
   * The density variant's real work. Most of this family's airiness comes from
   * this gap sitting on top of the description/meta leading, not from the
   * leading alone, so condensing has to tighten both.
   *
   * Deliberately a direct declaration rather than a component custom property:
   * selectable-row and action-row route their equivalent gap through one, but a
   * non-empty *.variables.json manifest obliges the DTCG corpus to model the
   * token, and that is a public theming API decision rather than a side effect
   * of fixing a no-op variant. Nothing outside this component reads the value.
   */
  .cinder-stacked-list-item[data-cinder-density='condensed'] .cinder-stacked-list-item__body {
    gap: var(--cinder-space-0-5);
  }

  .cinder-stacked-list-item__trailing {
    grid-area: trailing;
    display: flex;
    gap: var(--cinder-space-2);
    align-self: center;
    align-items: center;
  }

  /*
   * The long-value defaults, so no page has to fix them one at a time. A title takes at most two
   * lines (one with titleLines=1) and ends in an ellipsis; an unbroken value such as an
   * identifier wraps anywhere, so no value widens the row past its frame or grows it without bound.
   */
  .cinder-stacked-list-item__title,
  .cinder-stacked-list-item__description,
  .cinder-stacked-list-item__meta {
    min-inline-size: 0;
    overflow-wrap: anywhere;
  }

  .cinder-stacked-list-item__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    font-size: var(--cinder-text-sm);
    line-height: var(--cinder-leading-snug);
    color: var(--cinder-text-default);
  }

  .cinder-stacked-list-item__title[data-cinder-title-lines='1'] {
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }

  /* A mark after the title ("Plugin"): it sits 6px after the title on the first line's baseline,
   * outside the title's clamp. The title shrinks and clamps first; the mark is never cut and never
   * wraps onto a line of its own, because the two share one line that does not wrap. */
  .cinder-stacked-list-item__title-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: var(--cinder-space-1-5);
    min-inline-size: 0;
  }

  .cinder-stacked-list-item__title-row > .cinder-stacked-list-item__title {
    flex: 0 1 auto;
  }

  /* A mark of several badges (a run's states) is wider than a word: where it does not fit beside
   * the title it drops whole to a line under it, so the title keeps the row's width instead of
   * being crushed to a few letters. A single badge never wraps, as above. */
  .cinder-stacked-list-item__title-row:has(> .cinder-stacked-list-item__badge > :nth-child(2)) {
    flex-wrap: wrap;
    row-gap: var(--cinder-space-1);
  }

  /* The mark is one badge or several side by side (a run's states): the gap spaces them. */
  .cinder-stacked-list-item__badge {
    display: inline-flex;
    flex: none;
    gap: var(--cinder-space-1);
    white-space: nowrap;
  }

  .cinder-stacked-list-item__title-link {
    color: inherit;
    text-decoration: none;
  }

  /*
   * The whole row is one link: the anchor's pseudo-element covers the row, so a click anywhere
   * on it follows the link, hover tints the whole row, and the keyboard focus ring wraps the
   * whole row rather than the title. The ring is drawn inside the row because a list clips its
   * rows. Controls inside the row sit above the cover (see below), so they stay usable.
   */
  .cinder-stacked-list-item__title-link::after {
    content: '';
    position: absolute;
    inset: 0;
  }

  .cinder-stacked-list-item__title-link:focus-visible {
    outline: none;
  }

  .cinder-stacked-list-item__title-link:focus-visible::after {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow: inset 0 0 0 var(--cinder-ring-width) var(--cinder-ring-color);
  }

  @media (hover: hover) {
    .cinder-stacked-list-item--linked:hover {
      background: var(--cinder-surface-hover);
    }
  }

  /* Forced Colors Mode — box-shadow focus rings are invisible; use a real outline. */
  @media (forced-colors: active) {
    .cinder-stacked-list-item__title-link:focus-visible::after {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: calc(var(--cinder-ring-width) * -1);
    }
  }

  .cinder-stacked-list-item__trailing {
    position: relative;
    z-index: 1;
  }

  .cinder-stacked-list-item__line-two :is(a, button, [role='button']) {
    position: relative;
    z-index: 1;
  }

  .cinder-stacked-list-item__description {
    font-size: var(--cinder-text-sm);
    line-height: var(--cinder-leading-snug);
    color: var(--cinder-text-muted);
  }

  .cinder-stacked-list-item__meta {
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-snug);
    color: var(--cinder-text-muted);
  }

  .cinder-stacked-list-item[data-cinder-density='condensed'] .cinder-stacked-list-item__description,
  .cinder-stacked-list-item[data-cinder-density='condensed'] .cinder-stacked-list-item__meta {
    line-height: var(--cinder-leading-tight);
  }

  /* Narrow container query — trailing drops below body. A phone's one menu button (the collapsed
     actions) and a non-interactive trailing glyph such as a chevron are compact and stay beside
     the body. */
  @container cinder-stacked-list-item (max-width: 448px) {
    .cinder-stacked-list-item--has-trailing:not(
        .cinder-stacked-list-item--collapsed-actions,
        .cinder-stacked-list-item--trailing-glyph
      )
      .cinder-stacked-list-item__layout {
      grid-template-columns: 1fr;
      grid-template-areas:
        'body'
        'trailing';
    }

    .cinder-stacked-list-item--has-leading.cinder-stacked-list-item--has-trailing:not(
        .cinder-stacked-list-item--collapsed-actions,
        .cinder-stacked-list-item--trailing-glyph
      )
      .cinder-stacked-list-item__layout {
      grid-template-columns: auto 1fr;
      grid-template-areas:
        'leading body'
        'trailing trailing';
    }
  }

  /* ----------------------------------------
 * Status-first two-line row
 *
 * Line one: a status dot and word in a fixed 128px leading column (the same on every page, so
 * titles start at one x position down the list), a bold title, and the time at the right edge.
 * Line two: muted meta, which starts under the title and not under the status. The status and the
 * time sit on the baseline of the first line of the title (a title-sized strut gives each cell that
 * baseline) and stay there when the title clamps to a second line.
 *
 * The body is flattened into the layout grid so the status can lead the row, sit under the title
 * on a phone, or sit at the start of line two (the chat list), from one DOM order.
 * ---------------------------------------- */

  .cinder-stacked-list-item.cinder-stacked-list-item--lines:not([data-cinder-density='condensed']) {
    padding-block: var(--cinder-space-2-5);
    padding-inline: var(--cinder-space-3-5);
  }

  .cinder-stacked-list-item.cinder-stacked-list-item--lines > .cinder-stacked-list-item__layout {
    --_cinder-line-one-height: calc(var(--cinder-text-base) * var(--cinder-leading-snug));
    --_cinder-first-line: var(--_cinder-line-one-height);
    --_cinder-status-track: 0px;
    display: grid;
    align-items: start;
    column-gap: 0;
    row-gap: var(--cinder-space-0-5);
    grid-template-columns:
      [status] var(--_cinder-status-track) [leading] auto [title] minmax(0, 1fr) [time] auto
      [trailing] var(--cinder-stacked-list-item-trailing-track, auto);
    grid-template-areas:
      'status leading title time trailing'
      'status leading line line trailing'
      '. . details details .';
  }

  /* Reserved when the row has a status or the list keeps the column for rows with none. */
  .cinder-stacked-list-item--lines.cinder-stacked-list-item--status-column
    > .cinder-stacked-list-item__layout {
    --_cinder-status-track: calc(
      var(--cinder-stacked-list-item-status-track, var(--_cinder-status-width, 8rem)) +
        var(--cinder-space-3)
    );
  }

  /* Keep an opted-in status on the first line while metadata wraps from the leading edge. */
  @container cinder-stacked-list-item (max-width: 639.98px) {
    .cinder-stacked-list-item--lines.cinder-stacked-list-item--status-leading-always:not(
        [data-cinder-phone-width='viewport']
      )
      > .cinder-stacked-list-item__layout {
      --_cinder-status-track: max-content;
      grid-template-areas:
        'status leading title time trailing'
        'line line line line trailing'
        '. . details details .';
    }
  }

  .cinder-stacked-list-item--lines[data-cinder-phone-width='viewport'][data-cinder-phone].cinder-stacked-list-item--status-leading-always
    > .cinder-stacked-list-item__layout {
    --_cinder-status-track: max-content;
    grid-template-areas:
      'status leading title time trailing'
      'line line line line trailing'
      '. . details details .';
  }

  .cinder-stacked-list-item--lines
    > .cinder-stacked-list-item__layout
    > .cinder-stacked-list-item__body {
    display: contents;
  }

  .cinder-stacked-list-item--lines .cinder-stacked-list-item__status {
    grid-area: status;
    display: flex;
    align-items: baseline;
    min-block-size: var(--_cinder-line-one-height);
    min-inline-size: 0;
    padding-inline-end: var(--cinder-space-3);
    overflow: hidden;
    white-space: normal;
  }

  /* The status word and the time sit on the baseline of the title's first line. Each cell opens
     with a zero-width strut set in the title's type (the same size and line height, so its baseline
     is the title's), and the flex line aligns the word or the time to it. The negative end margin
     takes back the cell's gap so the strut moves nothing. The status dot stays centred on the word
     (see the dot rule below), so the dot and the word keep one optical line. */
  .cinder-stacked-list-item--lines .cinder-stacked-list-item__status::before,
  .cinder-stacked-list-item--lines .cinder-stacked-list-item__time::before {
    content: '\200b' / '';
    flex: none;
    inline-size: 0;
    margin-inline-end: calc(var(--_cinder-strut-gap, 0px) * -1);
    font-size: var(--cinder-text-base);
    line-height: var(--cinder-leading-snug);
  }

  /* Status on line two (the chat list, or a phone) sits beside 12px preview text, not the title,
     so it has no strut. */
  .cinder-stacked-list-item--lines.cinder-stacked-list-item--status-line-two
    .cinder-stacked-list-item__status::before {
    display: none;
  }

  /* The phone form is chosen by the row's own width, not the viewport's (COR-2448): every rule
     below that is "on a phone" sits in `@container cinder-stacked-list-item (max-width: 639.98px)`,
     which asks the row itself. `:not(.cinder-stacked-list-item--band)` is true of every two-line
     row (a band row is never one) and stands where the viewport attribute stood, so each rule
     keeps the specificity it had.

     A row that follows the window instead (`phoneWidth="viewport"`, marked
     `data-cinder-phone-width="viewport"`) is passed by every one of those queries, and takes the
     same rules from the script's phone mark, which it sets from the viewport: see "The phone form
     by the window" below. */
  @container cinder-stacked-list-item (max-width: 639.98px) {
    .cinder-stacked-list-item--lines:not(
        .cinder-stacked-list-item--band,
        [data-cinder-phone-width='viewport']
      ).cinder-stacked-list-item--status-leading
      .cinder-stacked-list-item__status::before {
      display: none;
    }
  }

  /* On a phone a title with a mark takes one line and ends in an ellipsis, so the mark sits 6px after
     the last character drawn. A title that wrapped would keep the width of its box, not of its last
     line, and leave the mark stranded beside a short first line (R10-01). The row's one tooltip is
     the whole name. */
  @container cinder-stacked-list-item (max-width: 639.98px) {
    .cinder-stacked-list-item:not([data-cinder-phone-width='viewport'])
      .cinder-stacked-list-item__title-row
      > .cinder-stacked-list-item__title {
      display: block;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .cinder-stacked-list-item[data-cinder-phone-width='viewport'][data-cinder-phone]
    .cinder-stacked-list-item__title-row
    > .cinder-stacked-list-item__title {
    display: block;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The dot centres on the word's line box while the word's baseline is the flex baseline. */
  .cinder-stacked-list-item__status .cinder-status-dot {
    align-items: center;
  }

  .cinder-stacked-list-item__status .cinder-status-dot__label {
    align-self: baseline;
  }

  /* A status in the column is a small dot (8px) and a 12px semibold word, so the longest word
     ("Waiting on you") fits the fixed width on every page. */
  .cinder-stacked-list-item__status .cinder-status-dot[data-cinder-size] {
    font-size: var(--cinder-text-xs);
  }

  .cinder-stacked-list-item__status .cinder-status-dot__indicator {
    inline-size: 0.5rem; /* 8px */
    block-size: 0.5rem;
  }

  .cinder-stacked-list-item--lines .cinder-stacked-list-item__leading {
    margin-inline-end: var(--cinder-space-3);
  }

  .cinder-stacked-list-item--lines .cinder-stacked-list-item__title {
    grid-area: title;
    font-size: var(--cinder-text-base);
    font-weight: var(--cinder-font-semibold);
  }

  /* With a mark, the title and the mark share the title's cell. */
  .cinder-stacked-list-item--lines .cinder-stacked-list-item__title-row {
    grid-area: title;
  }

  .cinder-stacked-list-item--lines .cinder-stacked-list-item__time {
    grid-area: time;
    display: flex;
    align-items: baseline;
    --_cinder-strut-gap: var(--cinder-space-2);
    gap: var(--_cinder-strut-gap);
    min-block-size: var(--_cinder-line-one-height);
    margin-inline-start: var(--cinder-space-3);
    font-size: var(--cinder-text-xs);
    font-variant-numeric: tabular-nums;
    color: var(--cinder-text-subtle);
    white-space: nowrap;
  }

  /* A time given as text: the day and the clock are each whole, wherever the time may wrap. */
  .cinder-stacked-list-item__time-part {
    white-space: nowrap;
  }

  .cinder-stacked-list-item--lines .cinder-stacked-list-item__line-two {
    grid-area: line;
    min-inline-size: 0;
  }

  /* Line two is one line of muted text that ends in an ellipsis rather than wrapping. */
  .cinder-stacked-list-item--lines .cinder-stacked-list-item__description,
  .cinder-stacked-list-item--lines .cinder-stacked-list-item__meta {
    overflow: hidden;
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-text-subtle);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* `metaLines={2}`: on a phone, line two takes a second line before it ends in an ellipsis. The
     row's own width decides, as it does for the phone form (a row that follows the window takes
     the same rule from the script's phone mark, as the title rule below does); wider, line two
     stays one line. */
  @container cinder-stacked-list-item (max-width: 639.98px) {
    .cinder-stacked-list-item--lines:not([data-cinder-phone-width='viewport'])
      .cinder-stacked-list-item__meta[data-cinder-meta-lines='2'] {
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      white-space: normal;
    }
  }

  .cinder-stacked-list-item--lines[data-cinder-phone-width='viewport'][data-cinder-phone]
    .cinder-stacked-list-item__meta[data-cinder-meta-lines='2'] {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    white-space: normal;
  }

  /* `wrapMeta`: line two carries a control, so it wraps and nothing on it is cut. */
  .cinder-stacked-list-item--lines.cinder-stacked-list-item--wrap-meta
    .cinder-stacked-list-item__meta {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  /* On a phone a `wrapMeta` row's line two is one run of text: the dot, the word, then the meta,
     across the status column and the text, so a wrapped line returns to the row's leading edge
     instead of wrapping in a narrow column beside the word. The row then draws its status there
     and not in the column (one copy, never two), and marks itself `--status-inline`; the script
     decides from the row's own width, as the phone form does, so these rules key on that class
     rather than a container query that could disagree with the markup for a frame. Rows without
     `wrapMeta` keep the status in its column. */
  .cinder-stacked-list-item--status-inline .cinder-stacked-list-item__line-two {
    /* `trailing-start`, not `trailing`: an end line named `trailing` resolves to the trailing
       area's implicit `trailing-end` line, which would run line two under the actions. */
    grid-column: status / trailing-start;
  }

  .cinder-stacked-list-item--status-inline .cinder-stacked-list-item__status-inline {
    display: inline-flex;
    vertical-align: baseline;
    margin-inline-end: var(--cinder-space-2);
    font-size: var(--cinder-text-xs);
  }

  .cinder-stacked-list-item__status-inline .cinder-status-dot__indicator {
    inline-size: 0.5rem; /* 8px, as in the status column */
    block-size: 0.5rem;
  }

  .cinder-stacked-list-item--status-inline
    :is(.cinder-stacked-list-item__meta, .cinder-stacked-list-item__description) {
    display: inline;
  }

  /* A third line (a phone schedule's reason and cadence): muted like line two, but it wraps, so
     nothing on it is cut. It shares the details row, which no row uses at the same time, and
     starts under the title; on a phone, where the status leads line two, it starts at the left
     edge under the status. */
  .cinder-stacked-list-item--lines .cinder-stacked-list-item__detail {
    grid-row: details;
    grid-column: 3 / 5;
    min-inline-size: 0;
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-text-subtle);
    overflow-wrap: anywhere;
  }

  @container cinder-stacked-list-item (max-width: 639.98px) {
    .cinder-stacked-list-item--lines:not(
        .cinder-stacked-list-item--band,
        [data-cinder-phone-width='viewport']
      )
      .cinder-stacked-list-item__detail {
      grid-column: 2 / 5;
    }
  }

  /* A row whose details failed to load (row 14q): line two is the message in the danger text
   * colour beside a warning glyph, and the row's own secondary "Try again" button at the end. It
   * wraps rather than truncating, because the message is the one thing the row has to say. */
  .cinder-stacked-list-item__error {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
    margin-block-start: var(--cinder-space-0-5);
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-status-danger-text);
  }

  .cinder-stacked-list-item__error-glyph {
    display: inline-flex;
    flex: none;
  }

  .cinder-stacked-list-item__error-message {
    flex: 1 1 auto;
    min-inline-size: 0;
    overflow-wrap: anywhere;
  }

  .cinder-stacked-list-item__error > .cinder-button {
    flex: none;
  }

  /*
   * The trailing region spans both lines and stays beside them. A list whose rows carry a figure
   * there (a cost, a count) passes `trailingTrack` to its DataList, which sets
   * `--cinder-stacked-list-item-trailing-track` on the list to the width of
   * its widest figure, so the track is the same in every row, with or without a trailing region, and
   * the times before it end at one edge. It sets `--cinder-stacked-list-item-trailing-align` to
   * `baseline` to hold the figure on the first line's baseline instead of centering it on both
   * lines. Both default to the row's own: a track sized by its content, and centered.
   */
  .cinder-stacked-list-item--lines .cinder-stacked-list-item__trailing {
    margin-inline-start: var(--cinder-space-3);
    align-self: var(--cinder-stacked-list-item-trailing-align, center);
  }

  /* A control has no useful text baseline. A list can instead put it in a box exactly as tall as
     line one, which centers the painted control with the status, title and time without changing
     the default two-line-centred trailing region. */
  @container cinder-stacked-list-item (min-width: 640px) {
    .cinder-data-list[data-cinder-trailing-align='line']
      .cinder-stacked-list-item--lines
      .cinder-stacked-list-item__trailing {
      align-self: start;
      block-size: var(--_cinder-line-one-height);
    }
  }

  /*
   * A narrow two-line row (the row's own width, 448px or less) that draws its actions as buttons
   * gives them a line of their own under the text, at the start of the text's column, instead of
   * a column beside it that would leave the title and the meta a few words wide. The title then
   * has the row's width and wraps to its two lines before it is cut. A phone's one menu button
   * (`--collapsed-actions`), a trailing glyph and the full-width buttons (`--phone-buttons`) are
   * not this class, and a row's trailing control that is not an action (a switch) stays beside.
   */
  @container cinder-stacked-list-item (max-width: 448px) {
    .cinder-stacked-list-item--lines.cinder-stacked-list-item--action-buttons:not(
        .cinder-stacked-list-item--single-action.cinder-stacked-list-item--status-leading
      )
      .cinder-stacked-list-item__trailing {
      grid-row: 4;
      grid-column: title / -1;
      align-self: start;
      margin-inline-start: 0;
      margin-block-start: var(--cinder-space-2);
    }
  }

  /* The chat list's exception: the pane is too narrow for a leading column, so line one is the
     title and the time, and line two is the status in its own fixed-width column, then the
     preview, so previews line up. A phone leading row takes the same shape with an unfixed width. */
  .cinder-stacked-list-item--lines.cinder-stacked-list-item--status-line-two
    > .cinder-stacked-list-item__layout {
    grid-template-columns:
      [leading] auto [status] var(--_cinder-status-track) [title] minmax(0, 1fr) [time] auto
      [trailing] var(--cinder-stacked-list-item-trailing-track, auto);
    grid-template-areas:
      'leading title title time trailing'
      'leading status line line trailing'
      '. . details details .';
  }

  @container cinder-stacked-list-item (max-width: 639.98px) {
    .cinder-stacked-list-item--lines:not(
        .cinder-stacked-list-item--band,
        [data-cinder-phone-width='viewport']
      ).cinder-stacked-list-item--status-leading
      > .cinder-stacked-list-item__layout {
      grid-template-columns:
        [leading] auto [status] var(--_cinder-status-track) [title] minmax(0, 1fr)
        [time] var(--_cinder-time-track, auto) [trailing] auto;
      grid-template-areas:
        'leading title title time trailing'
        'leading status line line trailing'
        '. . details details .';
    }
  }

  .cinder-stacked-list-item--lines.cinder-stacked-list-item--status-line-two.cinder-stacked-list-item--status-column
    > .cinder-stacked-list-item__layout {
    --_cinder-status-width: 6.5rem; /* 104px */
    --_cinder-status-track: calc(var(--_cinder-status-width) + var(--cinder-space-2));
  }

  .cinder-stacked-list-item--lines.cinder-stacked-list-item--status-line-two
    .cinder-stacked-list-item__status {
    align-items: center;
    min-block-size: calc(var(--cinder-text-xs) * var(--cinder-leading-normal));
    padding-inline-end: var(--cinder-space-2);
  }

  /* A narrow row puts a leading status on line two with no fixed column. The word is never cut: its
     track is the word's own width and the cell does not shrink below it, so the line's text and the
     time give way instead (R10-02). */
  @container cinder-stacked-list-item (max-width: 639.98px) {
    .cinder-stacked-list-item--lines:not(
        .cinder-stacked-list-item--band,
        [data-cinder-phone-width='viewport']
      ).cinder-stacked-list-item--status-leading
      > .cinder-stacked-list-item__layout {
      --_cinder-status-track: max-content;
    }

    /* A row with a trailing control (a hook's switch) shares line one between the title, the time
       and the control, so the time gives way before the title: a time given as text draws its day
       over its clock ("Yesterday," over "6:00 PM"), and its column is exactly its widest line
       (`min-content`), so the title takes all the rest. A time given as a snippet stays one line.
       A row with no trailing control, or whose actions drop under it, keeps its time on one line,
       and a group row's time track is never capped (its Show drops under the time only when the
       two cannot share a line; see the group row below). */
    .cinder-stacked-list-item--lines.cinder-stacked-list-item--has-trailing:not(
        .cinder-stacked-list-item--band,
        .cinder-stacked-list-item--group,
        .cinder-stacked-list-item--phone-buttons
      ).cinder-stacked-list-item--status-leading
      > .cinder-stacked-list-item__layout {
      --_cinder-time-track: min-content;
    }

    .cinder-stacked-list-item--lines:not(
        .cinder-stacked-list-item--band,
        [data-cinder-phone-width='viewport']
      ).cinder-stacked-list-item--status-leading
      .cinder-stacked-list-item__status {
      flex: none;
      align-items: center;
      min-inline-size: max-content;
      min-block-size: calc(var(--cinder-text-xs) * var(--cinder-leading-normal));
      padding-inline-end: 0;
    }

    .cinder-stacked-list-item--lines.cinder-stacked-list-item--has-trailing:not(
        .cinder-stacked-list-item--band,
        .cinder-stacked-list-item--group,
        .cinder-stacked-list-item--phone-buttons
      ).cinder-stacked-list-item--status-leading
      .cinder-stacked-list-item__time {
      text-align: end;
    }

    /* Only a time given as text wraps, and only between its parts. */
    .cinder-stacked-list-item--lines.cinder-stacked-list-item--has-trailing:not(
        .cinder-stacked-list-item--band,
        .cinder-stacked-list-item--group,
        .cinder-stacked-list-item--phone-buttons
      ).cinder-stacked-list-item--status-leading
      .cinder-stacked-list-item__time-text {
      white-space: normal;
    }

    /* On a phone the status moves to line two beside the kind and agent: "Waiting on you Chat".
       The status word (medium weight, the muted colour) and the line's text (regular weight, the
       subtle colour) are told apart by that step and a space, with no glyph between them: no
       comma and no dot (COR-2449). The space follows only a status that drew something
       (`:has(*)`), so a row whose status snippet drew nothing starts line two flush. */
    .cinder-stacked-list-item--lines:not(
        .cinder-stacked-list-item--band,
        [data-cinder-phone-width='viewport']
      ).cinder-stacked-list-item--status-leading:not(.cinder-stacked-list-item--no-line-two)
      .cinder-stacked-list-item__status:has(*) {
      margin-inline-end: var(--cinder-space-1-5);
    }
  }

  /* The phone form by the window (`phoneWidth="viewport"`): the rules of the container queries
     above, for a row the script marks as a phone while the viewport is below 640px. A
     list that fills the page's content column follows the window, so a tablet whose navigation
     rail narrows the row below 640px still leads with the status column (rows 05w, 05x). */
  .cinder-stacked-list-item--lines[data-cinder-phone-width='viewport'][data-cinder-phone].cinder-stacked-list-item--status-leading
    .cinder-stacked-list-item__status::before {
    display: none;
  }

  .cinder-stacked-list-item--lines[data-cinder-phone-width='viewport'][data-cinder-phone]
    .cinder-stacked-list-item__detail {
    grid-column: 2 / 5;
  }

  .cinder-stacked-list-item--lines[data-cinder-phone-width='viewport'][data-cinder-phone].cinder-stacked-list-item--status-leading
    > .cinder-stacked-list-item__layout {
    --_cinder-status-track: max-content;
    grid-template-columns:
      [leading] auto [status] var(--_cinder-status-track) [title] minmax(0, 1fr) [time] auto
      [trailing] auto;
    grid-template-areas:
      'leading title title time trailing'
      'leading status line line trailing'
      '. . details details .';
  }

  .cinder-stacked-list-item--lines[data-cinder-phone-width='viewport'][data-cinder-phone].cinder-stacked-list-item--status-leading
    .cinder-stacked-list-item__status {
    flex: none;
    align-items: center;
    min-inline-size: max-content;
    min-block-size: calc(var(--cinder-text-xs) * var(--cinder-leading-normal));
    padding-inline-end: 0;
  }

  /* A viewport-width phone row gives the status its full word. Its timestamp must then reflow at
     large text rather than widening the list past the viewport; the run list uses a time snippet,
     so this belongs on the time cell rather than only on the text-value form below. */
  .cinder-stacked-list-item--lines[data-cinder-phone-width='viewport'][data-cinder-phone].cinder-stacked-list-item--status-leading:not(
      .cinder-stacked-list-item--group
    )
    .cinder-stacked-list-item__time {
    text-align: end;
    white-space: normal;
  }

  .cinder-stacked-list-item--lines[data-cinder-phone-width='viewport'][data-cinder-phone].cinder-stacked-list-item--status-leading:not(
      .cinder-stacked-list-item--no-line-two
    )
    .cinder-stacked-list-item__status:has(*) {
    margin-inline-end: var(--cinder-space-1-5);
  }

  /* The generic narrow rule predates lines, whose body wrapper is flattened into this grid. Keep a
     single action below the real title and line cells rather than creating an implicit `body` row.
     This comes after both phone-width forms so an ordinary action gets the same usable text tracks
     whether its phone state follows the row or the viewport. Menus, glyphs, and explicit phone
     buttons each retain their compact or full-width arrangements. */
  @container cinder-stacked-list-item (max-width: 448px) {
    .cinder-stacked-list-item--lines.cinder-stacked-list-item--single-action:not(
        .cinder-stacked-list-item--collapsed-actions,
        .cinder-stacked-list-item--trailing-glyph,
        .cinder-stacked-list-item--phone-buttons
      ).cinder-stacked-list-item--status-leading
      > .cinder-stacked-list-item__layout {
      grid-template-columns:
        [status] var(--_cinder-status-track) [leading] auto [title] minmax(0, 1fr)
        [time] var(--_cinder-time-track, auto);
      grid-template-areas:
        'status leading title time'
        'status leading line line'
        'trailing trailing trailing trailing'
        '. . details details';
    }

    .cinder-stacked-list-item--lines.cinder-stacked-list-item--has-leading.cinder-stacked-list-item--single-action:not(
        .cinder-stacked-list-item--collapsed-actions,
        .cinder-stacked-list-item--trailing-glyph,
        .cinder-stacked-list-item--phone-buttons
      ).cinder-stacked-list-item--status-leading
      > .cinder-stacked-list-item__layout {
      grid-template-columns:
        [leading] auto [status] var(--_cinder-status-track) [title] minmax(0, 1fr)
        [time] var(--_cinder-time-track, auto);
      grid-template-areas:
        'leading title title time'
        'leading status line line'
        'trailing trailing trailing trailing'
        '. . details details';
    }

    /* These specialized third-row layouts retain the generic action's compact spacing, but their
       text starts at different named columns. A leading tile makes the visual title begin at the
       status line; without one it begins at the actual title line. */
    .cinder-stacked-list-item--lines.cinder-stacked-list-item--single-action:not(
        .cinder-stacked-list-item--has-leading,
        .cinder-stacked-list-item--collapsed-actions,
        .cinder-stacked-list-item--trailing-glyph,
        .cinder-stacked-list-item--phone-buttons
      ).cinder-stacked-list-item--status-leading
      .cinder-stacked-list-item__trailing {
      grid-column: title / -1;
      align-self: start;
      margin-inline-start: 0;
      margin-block-start: var(--cinder-space-2);
    }

    .cinder-stacked-list-item--lines.cinder-stacked-list-item--has-leading.cinder-stacked-list-item--single-action:not(
        .cinder-stacked-list-item--collapsed-actions,
        .cinder-stacked-list-item--trailing-glyph,
        .cinder-stacked-list-item--phone-buttons
      ).cinder-stacked-list-item--status-leading
      .cinder-stacked-list-item__trailing {
      grid-column: status / -1;
      align-self: start;
      margin-inline-start: 0;
      margin-block-start: var(--cinder-space-2);
    }

    /* The ordinary inline-status form stops before a trailing column. These dedicated action
       layouts instead put the action in their third row, so that generated line starts at column
       one. Let line two span the real row tracks without sending it back to that line. */
    .cinder-stacked-list-item--lines.cinder-stacked-list-item--single-action:not(
        .cinder-stacked-list-item--collapsed-actions,
        .cinder-stacked-list-item--trailing-glyph,
        .cinder-stacked-list-item--phone-buttons
      ).cinder-stacked-list-item--status-inline
      .cinder-stacked-list-item__line-two {
      grid-column: status / -1;
    }
  }

  /* The chat list's line-two status gives up its fixed column on a phone only (COR-2016): the
     word, a space, then the latest message. This one asks the viewport, not the row: the line-two
     placement exists for a narrow pane, where the fixed column is what lines the previews up, so
     the row's own width must not take the column away in a pane of a wide window. The row marks
     itself `data-cinder-viewport-phone` from the shared phone viewport state. */
  .cinder-stacked-list-item--lines[data-cinder-viewport-phone].cinder-stacked-list-item--status-line-two
    > .cinder-stacked-list-item__layout {
    --_cinder-status-track: auto;
  }

  .cinder-stacked-list-item--lines[data-cinder-viewport-phone].cinder-stacked-list-item--status-line-two
    .cinder-stacked-list-item__status {
    align-items: center;
    min-block-size: calc(var(--cinder-text-xs) * var(--cinder-leading-normal));
    padding-inline-end: 0;
  }

  .cinder-stacked-list-item--lines[data-cinder-viewport-phone].cinder-stacked-list-item--status-line-two
    .cinder-stacked-list-item__status:has(*) {
    margin-inline-end: var(--cinder-space-1-5);
  }

  /* ----------------------------------------
 * Group row (a collapsed row with a disclosure)
 * ---------------------------------------- */

  /* A group row is always tinted, so it reads as a different kind of row (not a run) among its
     neighbours, open or shut. The warning tone is the amber of something that did not happen. */
  .cinder-stacked-list-item--group.cinder-stacked-list-item--tone-neutral {
    background: color-mix(in oklch, var(--cinder-surface-inset), transparent 50%);
  }

  .cinder-stacked-list-item--group.cinder-stacked-list-item--tone-warning {
    background: color-mix(in oklch, var(--cinder-status-warning-background), transparent 40%);
  }

  /* Open, a group row shows all of its line two instead of ending it in an ellipsis. */
  .cinder-stacked-list-item--group[data-cinder-expanded] .cinder-stacked-list-item__description,
  .cinder-stacked-list-item--group[data-cinder-expanded] .cinder-stacked-list-item__meta {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  /* ----------------------------------------
 * Band group row: the missed runs among one schedule's runs. One line: the status dot, then a
 * tinted band holding a chevron, the bold title, muted text and the disclosure label at the right.
 * The whole band is the button, so a click anywhere on it opens the details.
 * ---------------------------------------- */

  .cinder-stacked-list-item--band,
  .cinder-stacked-list-item--band.cinder-stacked-list-item--group {
    padding-block: var(--cinder-space-1);
    padding-inline: 0;
    background: transparent;
  }

  .cinder-stacked-list-item__band-line {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
  }

  .cinder-stacked-list-item__band-status {
    display: inline-flex;
    flex: none;
    align-items: center;
  }

  .cinder-stacked-list-item__band-surface {
    flex: 1 1 auto;
    min-inline-size: 0;
    border-radius: var(--cinder-radius-md);
    background: color-mix(in oklch, var(--cinder-surface-inset), transparent 50%);
  }

  .cinder-stacked-list-item--tone-warning .cinder-stacked-list-item__band-surface {
    background: var(--cinder-status-warning-background);
    color: var(--cinder-status-warning-text);
  }

  .cinder-stacked-list-item__band-toggle {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
    inline-size: 100%;
    min-block-size: max(var(--cinder-list-row-min-height), var(--cinder-space-8));
    padding-block: var(--cinder-space-1);
    padding-inline: var(--cinder-space-2-5);
    border: 0;
    border-radius: inherit;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: var(--cinder-text-sm);
    text-align: start;
    cursor: pointer;
  }

  .cinder-stacked-list-item__band-toggle:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow: var(--_cinder-focus-ring-shadow);
  }

  .cinder-stacked-list-item__band-title {
    flex: 0 1 auto;
    min-inline-size: 0;
    overflow: hidden;
    font-weight: var(--cinder-font-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cinder-stacked-list-item__band-meta {
    flex: 1 1 0;
    min-inline-size: 0;
    overflow: hidden;
    color: var(--cinder-text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cinder-stacked-list-item--tone-warning .cinder-stacked-list-item__band-meta {
    color: inherit;
  }

  .cinder-stacked-list-item__band-label {
    flex: none;
    margin-inline-start: auto;
    font-weight: var(--cinder-font-semibold);
    white-space: nowrap;
  }

  .cinder-stacked-list-item--band .cinder-stacked-list-item__details {
    padding-inline-start: var(--cinder-space-2-5);
  }

  @media (forced-colors: active) {
    .cinder-stacked-list-item__band-surface {
      border: 1px solid CanvasText;
    }

    .cinder-stacked-list-item__band-toggle:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 2px;
    }
  }

  /* ----------------------------------------
 * The selected row (the one open in the detail beside the list) and the glyph tile
 * ---------------------------------------- */

  /* The selected row takes `--cinder-selected-background`, the one selected fill the sidebar's
   * current page shares, so a list and the navigation beside it read as one recipe. Hovering it
   * deepens the same tint a step toward the accent. */
  .cinder-stacked-list-item.cinder-stacked-list-item--selected {
    background: var(--cinder-selected-background);
  }

  @media (hover: hover) {
    .cinder-stacked-list-item--linked.cinder-stacked-list-item--selected:hover {
      background: color-mix(
        in oklch,
        var(--cinder-selected-background),
        var(--cinder-accent-solid) 5%
      );
    }
  }

  @media (forced-colors: active) {
    .cinder-stacked-list-item--selected {
      outline: 1px solid Highlight;
      outline-offset: -1px;
    }
  }

  .cinder-stacked-list-item__leading-tile {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    inline-size: var(--cinder-space-8);
    block-size: var(--cinder-space-8);
    border-radius: var(--cinder-radius-md);
    background: var(--cinder-status-neutral-background);
    color: var(--cinder-status-neutral-text);
  }

  .cinder-stacked-list-item__leading-tile[data-cinder-tone='info'] {
    background: var(--cinder-status-info-background);
    color: var(--cinder-status-info-text);
  }

  .cinder-stacked-list-item__leading-tile[data-cinder-tone='success'] {
    background: var(--cinder-status-success-background);
    color: var(--cinder-status-success-text);
  }

  .cinder-stacked-list-item__leading-tile[data-cinder-tone='warning'] {
    background: var(--cinder-status-warning-background);
    color: var(--cinder-status-warning-text);
  }

  .cinder-stacked-list-item__leading-tile[data-cinder-tone='danger'] {
    background: var(--cinder-status-danger-background);
    color: var(--cinder-status-danger-text);
  }

  /* The tile is centred on the two lines beside it. */
  .cinder-stacked-list-item--lines.cinder-stacked-list-item--has-leading-tile
    .cinder-stacked-list-item__leading {
    align-self: center;
  }

  /* A group row's time and its Show share one line while they fit, which at the normal text size
     they do even at 320px: the time's track is `auto`, so it takes its whole width before the title
     takes the rest. Where they cannot (200% text on a phone), Show drops whole to a line of its own
     under the time rather than pushing the row past the page. Each keeps `nowrap`, so the only
     break is between the two. */
  .cinder-stacked-list-item--lines.cinder-stacked-list-item--group .cinder-stacked-list-item__time {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 0;
  }

  /* The control is one word and a chevron: it never shrinks or breaks, whatever its cell does. */
  .cinder-stacked-list-item__disclosure {
    --_cinder-disclosure-target: var(--cinder-space-6);
    position: relative;
    z-index: 1;
    flex: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: var(--cinder-space-1-5);
    min-block-size: var(--cinder-list-row-min-height);
    padding: 0;
    border: 0;
    border-radius: var(--cinder-radius-sm);
    background: transparent;
    color: var(--cinder-text-subtle);
    font: inherit;
    font-size: var(--cinder-text-xs);
    cursor: pointer;
  }

  /* Keep the painted label compact. Give both vertical edges a pixel for hit-test rounding. */
  .cinder-stacked-list-item__disclosure::before {
    content: '';
    position: absolute;
    inset-block: min(0px, calc((100% - var(--_cinder-disclosure-target)) / 2 - 1px));
    inset-inline: min(0px, calc((100% - var(--_cinder-disclosure-target)) / 2));
  }

  .cinder-stacked-list-item__disclosure:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow: var(--_cinder-focus-ring-shadow);
  }

  @media (forced-colors: active) {
    .cinder-stacked-list-item__disclosure:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 2px;
    }
  }

  .cinder-stacked-list-item__details {
    grid-area: details;
    min-inline-size: 0;
    padding-block: var(--cinder-space-2) var(--cinder-space-1);
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-muted);
  }

  /* ----------------------------------------
 * Trailing actions: buttons on a tablet or desktop, one menu button on a phone
 * ---------------------------------------- */

  .cinder-stacked-list-item__actions {
    display: inline-flex;
    align-items: center;
    gap: var(--cinder-space-2);
  }

  /* A phone row that keeps its actions as buttons: they sit under the text, one per line, each the
     full width of the row. */
  .cinder-stacked-list-item--phone-buttons .cinder-stacked-list-item__trailing {
    inline-size: 100%;
    margin-inline-start: 0;
    margin-block-start: var(--cinder-space-2);
  }

  /* A two-line row keeps its trailing region beside the lines; here it takes a row of its own under
     them, across every column. */
  .cinder-stacked-list-item.cinder-stacked-list-item--lines.cinder-stacked-list-item--phone-buttons
    > .cinder-stacked-list-item__layout {
    grid-template-columns:
      [status] var(--_cinder-status-track) [leading] auto [title] minmax(0, 1fr)
      [time] auto;
    grid-template-areas:
      'status leading title time'
      'status leading line line'
      'trailing trailing trailing trailing'
      '. . details details';
  }

  /* `--phone-buttons` is set only on a row narrower than 640px, the same row the phone-form
     container query above asks about. */
  .cinder-stacked-list-item--lines.cinder-stacked-list-item--phone-buttons:not(
      .cinder-stacked-list-item--band
    ).cinder-stacked-list-item--status-leading
    > .cinder-stacked-list-item__layout {
    grid-template-columns:
      [leading] auto [status] var(--_cinder-status-track) [title] minmax(0, 1fr)
      [time] var(--_cinder-time-track, auto);
    grid-template-areas:
      'leading title title time'
      'leading status line line'
      'trailing trailing trailing trailing'
      '. . details details';
  }

  .cinder-stacked-list-item--phone-buttons .cinder-stacked-list-item__actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    inline-size: 100%;
  }

  .cinder-stacked-list-item--phone-buttons .cinder-stacked-list-item__actions > .cinder-button {
    inline-size: 100%;
  }

  .cinder-stacked-list-item__reason {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* The menu button is a square icon button drawn at the compact height of a small Button, the
     same as the secondary buttons it replaces beside the other rows. Under a coarse pointer it
     reaches the 44px touch target through a positioned pseudo-element that takes no layout, as
     Button does, so the row is never taller for it. */
  .cinder-stacked-list-item .cinder-stacked-list-item__actions-trigger.cinder-dropdown-trigger {
    position: relative;
    inline-size: var(--_cinder-painted-height-sm);
    min-inline-size: var(--_cinder-painted-height-sm);
    block-size: var(--_cinder-painted-height-sm);
    min-block-size: var(--_cinder-painted-height-sm);
    padding-inline: 0;
    padding-block: 0;
  }

  @media (any-pointer: coarse) {
    .cinder-stacked-list-item__disclosure {
      --_cinder-disclosure-target: var(--cinder-touch-target-min);
      min-block-size: 0;
    }

    .cinder-stacked-list-item .cinder-stacked-list-item__actions-trigger::before {
      content: '';
      position: absolute;
      inset-block: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
      inset-inline: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
    }
  }
}
