/* Kleto Pulse card band (owner ruling 2026-10-29, docs/DESIGN-TASTE.md;
   card-band.js). Composed by the band's own width (a container query, so
   the large screen zoom of screens.css keeps the desktop layout):
     from 880px  one row: Projects and its count, the search (it grows),
                 Sort, Filter, then Groups | Projects at the end;
     under 880   two rows: the title with the switch, then the bar; under
                 600px of bar width Sort and Filter turn into square icon
                 buttons (the shared .ui-bar hides their labels).
   One control height (--ui-ctl-h: 40px with a mouse, 44px on touch), 8px
   corners and 8px gaps from the shared layer. Every row has a fixed height
   from first paint; the active filter row shows only after a filter is
   chosen. */

#portfolio {
  container: cb / inline-size;
  --ui-ctl-line: #646464;
  --ui-sel-edge: var(--home-accent);
  --ui-badge-ground: var(--home-accent);
  --ui-badge-ink: var(--home-on-accent, #000);
  --cb-text: 13px;
  margin: 18px 0 14px;
}
:root[data-theme="light"] #portfolio { --ui-ctl-line: #86868b; }
#app #portfolio.portfolio { border-bottom: 0; padding-bottom: 0; }
.cb {
  display: grid; align-items: center; gap: 8px 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "head view" "bar bar";
}
.cb__head { grid-area: head; display: flex; align-items: baseline; gap: 10px; min-width: 0; min-height: var(--ui-ctl-h, 40px); align-self: center; }
.cb__head { align-items: center; }
.cb__bar { grid-area: bar; }
.cb__view { grid-area: view; justify-self: end; }
@container cb (min-width: 880px) {
  .cb { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "head bar view"; }
}

/* The title: one word and its count, no sentence. */
.cb__title { margin: 0; display: flex; align-items: baseline; gap: 8px; font-size: 18px; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; }
/* The count keeps a reserved slot, so its first number (it arrives with
   the site list) widens nothing: the bar beside it never moves. */
.cb__count { display: inline-block; min-width: 4ch; color: var(--dim); font: 400 12px var(--mono); letter-spacing: .02em; font-variant-numeric: tabular-nums slashed-zero; }
/* Organization reads and saves speak through the polite status, which
   takes no space. An error shows as a fixed notice with Retry at the foot
   of the screen (above the dock on a phone), so neither a passing message
   nor an error ever moves the band. */
.cb__head { position: relative; }
.cb__notice { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.cb__notice.is-error {
  position: fixed; left: 50%; top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 25;
  width: min(520px, calc(100vw - 32px)); height: auto; overflow: visible; clip-path: none; white-space: normal;
  transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--down); border-radius: 8px; background: var(--panel); box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.cb__notice .cb__status { margin: 0; flex: 1 1 auto; min-width: 0; font-size: 13px; line-height: 1.4; color: var(--text); }
.cb__retry[hidden] { display: none; }
@media (max-width: 759px) { .cb__notice.is-error { bottom: calc(92px + env(safe-area-inset-bottom)); } }

/* The bar: the shared shell maps every control to the band height. */
.cb__bar { --ui-text: var(--cb-text); --ui-text-sm: var(--cb-text); }
/* The layer sizes and edges the band buttons; Pulse sets the ground,
   the ink and the text step. */
#portfolio .cb__bar { --ui-raised: var(--card); }
.cb__bar .ui-btn, .cb__bar .ui-menubtn { color: var(--text); font-size: var(--cb-text); }
.cb__bar .ico { width: 16px; height: 16px; flex: none; }
.cb__sort { flex: none; }
.cb__sortbtn .ui-menubtn__value { max-width: 11em; }
.cb__filterbtn { flex: none; position: relative; }
/* The filter count is the layer's corner badge (it never moves anything),
   in the one accent. */
.cb__n { font-family: var(--mono); }

/* The search field is the layer's .ui-search (its icon, clear button and
   "/" hint); Pulse gives it the card ground and the band text size.
   app.css styles every bare input for the login form, unlayered, so the
   layer's edge (3:1), corners and padding are restated here. */
.cb__search { --ui-raised: var(--card); --ui-accent: var(--home-accent); --ui-text: var(--cb-text); }
#app .ui-search > input {
  min-height: 0; padding: 0 var(--ui-ctl-h, 40px) 0 36px;
  border: 1px solid var(--ui-ctl-line, #646464); border-radius: var(--ui-ctl-r, 8px);
  background: var(--card); font: var(--ui-text, 14px) var(--body);
}
#app .ui-search > input:focus { border-color: var(--home-accent); box-shadow: 0 0 0 1px var(--home-accent); }
#app .ui-search > input::placeholder { color: var(--faint); }
@media (pointer: coarse) { #app .ui-search > input { font-size: 16px; } }

/* Groups | Projects is the layer's segmented control (data-ui-seg): the
   track takes the band height, the thumb the selected state. Under 340px
   of band width the segments fold to their icons. */
.cb__view .ui-seg { --ui-rail: var(--card); font-size: var(--cb-text); }
.cb[data-flat] .cb__view .ui-seg > [data-sc-mode="groups"][aria-checked="true"] { box-shadow: none; border-color: var(--ui-ctl-line); background: transparent; }
@container cb (max-width: 340px) {
  .cb__view .ui-seg > * > .ui-seg__icon { display: block; }
  .cb__view .ui-seg > * > .ui-seg__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .cb__view .ui-seg > button { width: calc(var(--ui-ctl-h, 40px) - 6px); padding: 0; justify-content: center; }
}

/* The active filters: removable chips and Clear all, one row that scrolls
   sideways when it must (never a ragged stack). */
.cb__active { display: flex; align-items: center; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin-inline: -2px; }
.cb__active::-webkit-scrollbar { display: none; }
.cb__active[hidden] { display: none; }
.cb__active .ui-chip { flex: none; height: 32px; border-radius: var(--ui-ctl-r, 8px); color: var(--text); font-size: 12px; gap: 6px; padding: 0 8px 0 12px; border-color: var(--ui-sel-edge); background: color-mix(in srgb, var(--ui-sel-edge) 12%, transparent); }
.cb__active .ui-chip .ico { width: 14px; height: 14px; }
.cb__clear { flex: none; height: 32px; font-size: 12px; }
@media (pointer: coarse) { .cb__active .ui-chip, .cb__clear { height: 44px; min-height: 44px; } }

/* The filter sheet: quick filters first, then the families. */
.cb-filter { width: min(520px, 100vw); --ui-sel-edge: var(--home-accent); }
.cb-filter .ui-sheet-head { display: flex; align-items: center; gap: 12px; }
.cb-filter .ui-sheet-head h2 { margin: 0; }
.cb-filter .ui-sheet-head .ui-iconbtn { margin-left: auto; }
.cb-filter__n { color: var(--dim); font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.cb-filter__body { display: flex; flex-direction: column; gap: 16px; padding: 4px 0 8px; }
.cb-filter__k { margin: 0 0 8px; font: 400 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.cb-filter__chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* A toggle chip inside the shared sheet takes the band's selected state. */
.cb-filter .ui-chip { height: var(--ui-ctl-h, 40px); border-radius: var(--ui-ctl-r, 8px); border-color: var(--ui-ctl-line); color: var(--text); font-size: 13px; }
.cb-filter .ui-chip[aria-pressed="true"] { font-weight: 600; }
.cb-filter .ui-sheet-foot { justify-content: space-between; }
.pf-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.pf-dot--up { background: var(--up); }
.pf-dot--warn { background: var(--warn); border-radius: 1px; transform: rotate(45deg) scale(.85); }
.pf-dot--down { background: var(--down); border-radius: 1px; }

/* A card that stopped matching a filter waits, dimmed, for the next
   re-order (live-order.js): it never vanishes under a finger. */
#sites .card.is-stale { opacity: .45; }
/* A first visit waits for the group read with its height held, so the
   panels below never jump into view. */
#sites[data-pending] { min-height: 100vh; }

@media (forced-colors: active) {
}
/* The large screen class: a larger band text step (14px and up before the
   2.25x zoom reads 32px or more at 4K). */
@media (min-width: 2400px) { #portfolio { --cb-text: 15px; } .cb__title { font-size: 20px; } }
@media (prefers-reduced-motion: reduce) { #sites .card.is-stale { transition: none; } }
