/* Parcel — shared components (js/ui/*). Reference: docs/FOUNDATION.md */

/* Only the root: locking body too would turn it into a scroll container and unstick the sidebar/nav bar. */
html.is-locked { overflow: hidden; }

/* ---------------------------------------------------------------- tone variables
   Any element with .tone-<name> gets --tone (the colour) and --tone-text (an AA-safe text shade). */
.tone-green  { --tone: var(--green);  --tone-text: var(--green-text); }
.tone-red    { --tone: var(--red);    --tone-text: var(--red-text); }
.tone-orange { --tone: var(--orange); --tone-text: var(--orange-text); }
.tone-yellow { --tone: var(--yellow); --tone-text: var(--yellow-text); }
.tone-blue, .tone-accent { --tone: var(--accent); --tone-text: var(--accent-text); }
.tone-indigo { --tone: var(--indigo); --tone-text: var(--indigo-text); }
.tone-teal   { --tone: var(--teal);   --tone-text: var(--teal-text); }
.tone-pink   { --tone: var(--pink);   --tone-text: var(--pink-text); }
.tone-purple { --tone: var(--purple); --tone-text: var(--purple-text); }
.tone-gray   { --tone: var(--gray);   --tone-text: var(--gray-text); }
.tone-secondary { --tone: var(--label-2); --tone-text: var(--label-2); }
.tone-label  { --tone: var(--label);  --tone-text: var(--label); }

/* ---------------------------------------------------------------- hit slop
   Small controls keep their look but get a ≥ 44×44 hit area (HIG), centred on the control, via an invisible
   ::after that grows each side only as far as needed (never shrinks a big control). Add .hit-slop to any small
   custom tappable (text links in headers, (i) glyphs, row tokens). z-index 1 lets the slop win the few pixels
   it overlaps a neighbouring row's padding. Notes: the element must not need ::after for something else (a
   more specific ::after rule simply replaces the slop) and an overflow:hidden/auto ancestor clips it. */
:is(.hit-slop, .card-action, .list-header-action, .section-action, .info-btn, .search-field, .search-clear, .toast-action,
    .btn-small, .btn-medium, .chip, .segmented-item, .inline-field) { position: relative; }
:is(.hit-slop, .card-action, .list-header-action, .section-action, .info-btn, .search-field, .search-clear, .toast-action,
    .btn-small, .btn-medium, .chip, .segmented-item, .inline-field)::after {
  content: ""; position: absolute; z-index: 1;
  inset: min(0px, calc(50% - var(--hit) / 2));
}

/* ---------------------------------------------------------------- spinner */
.spinner { display: inline-grid; place-items: center; color: var(--label-2); flex: none; }
.spinner svg { animation: parcel-spin .8s steps(8, end) infinite; }
@keyframes parcel-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner svg { animation-duration: .8s !important; animation-iteration-count: infinite !important; }
}

/* ---------------------------------------------------------------- buttons */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  font-weight: var(--w-semibold);
  letter-spacing: -0.2px;
  white-space: nowrap;
  text-align: center;
  transition: transform var(--dur-press) var(--ease), opacity var(--dur-press) var(--ease), background-color var(--dur-fast) linear, filter var(--dur-fast) linear;
  -webkit-tap-highlight-color: transparent;
}
.btn-content { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; }
.btn-label { overflow: hidden; text-overflow: ellipsis; }
.btn-large  { min-height: 50px; padding: 0 26px; font-size: 17px; }
.btn-medium { min-height: 40px; padding: 0 18px; font-size: 15px; }
.btn-small  { min-height: 30px; padding: 0 13px; font-size: 14px; }
.btn-block  { display: flex; width: 100%; }
.btn-primary { background: var(--accent-fill); color: #fff; }
.btn-tinted  { background: var(--accent-tint); color: var(--accent-text); }
.btn-gray    { background: var(--fill-3); color: var(--accent-text); }
.btn-plain   { background: transparent; color: var(--accent-text); padding-inline: 10px; }
.btn-destructive { background: var(--destructive-fill); color: #fff; }
.btn-destructive-tinted { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red-text); }
.btn:active { transform: scale(.97); opacity: .82; }
.btn-plain:active { transform: none; opacity: .45; }
/* Pointer hover (Mac/iPad trackpad). Fills darken a step; text keeps ≥ 4.5:1 in both themes. */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled), .btn-destructive:hover:not(:disabled) { filter: brightness(.92); }
  .btn-tinted:hover:not(:disabled) { background: var(--accent-tint-hover); }
  .btn-gray:hover:not(:disabled) { background: var(--fill-hover); }
  .btn-plain:hover:not(:disabled) { background: var(--fill-4); }
  .btn-destructive-tinted:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 18%, transparent); }
  .icon-btn:hover:not(:disabled) { background: var(--fill-4); }
  .icon-btn-gray:hover:not(:disabled) { background: none; }
  .icon-btn-gray:hover:not(:disabled) .icon-btn-face { background: var(--fill-hover); }
  .icon-btn-tinted:hover:not(:disabled), .icon-btn-filled:hover:not(:disabled) { background: none; }
  .icon-btn-tinted:hover:not(:disabled) .icon-btn-face { background: var(--accent-tint-hover); }
  .icon-btn-filled:hover:not(:disabled) .icon-btn-face { filter: brightness(.92); }
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; transform: none; filter: none; cursor: default; }
.btn-primary:disabled:not(.is-loading) { background: var(--fill); color: var(--label-2); opacity: 1; }
.btn.is-loading { opacity: 1; }
.btn.is-loading .btn-content { visibility: hidden; }
.btn > .spinner { position: absolute; inset: 0; margin: auto; color: currentColor; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  color: var(--accent-text);
  border-radius: 50%;
  transition: background-color var(--dur-fast) linear;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn-face { display: grid; place-items: center; border-radius: 50%; transition: opacity var(--dur-press) linear, transform var(--dur-press) var(--ease); }
.icon-btn-gray .icon-btn-face    { width: 30px; height: 30px; background: var(--fill-3); color: var(--label-2); }
.icon-btn-tinted .icon-btn-face  { width: 32px; height: 32px; background: var(--accent-tint); color: var(--accent-text); }
.icon-btn-filled .icon-btn-face  { width: 32px; height: 32px; background: var(--accent-fill); color: #fff; }
.icon-btn-small .icon-btn-face   { width: 26px; height: 26px; }
.icon-btn:active .icon-btn-face  { opacity: .45; }
.icon-btn-filled:active .icon-btn-face, .icon-btn-tinted:active .icon-btn-face { opacity: .7; transform: scale(.94); }
.icon-btn:disabled { color: var(--label-3); }

/* ---------------------------------------------------------------- inset grouped list */
.list-section { min-width: 0; }
.list-section + .list-section { margin-top: var(--sp-7); }
.list-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3);
  padding: 0 16px 7px;
}
.list-header-title {
  font-size: 13px; line-height: 18px; font-weight: var(--w-regular);
  color: var(--label-2);
  text-transform: uppercase; letter-spacing: 0;
}
.list-header.is-prominent { padding: 0 4px 10px; }
.list-header.is-prominent .list-header-title {
  font-size: var(--fs-title3); line-height: var(--lh-title3); font-weight: var(--w-bold);
  color: var(--label); text-transform: none; letter-spacing: var(--ls-title3);
}
.list-header-action { font-size: 15px; line-height: 20px; color: var(--accent-text); white-space: nowrap; }
.list-header-action:active { opacity: .45; }
@media (hover: hover) and (pointer: fine) {
  :is(.list-header-action, .card-action, .section-action):hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
}
.list {
  background: var(--bg-2);
  border-radius: var(--r-list);
  overflow: hidden;
}
.list-footer { padding: 7px 16px 0; font-size: 13px; line-height: 18px; color: var(--label-2); text-wrap: pretty; }

.list-row-inner {
  position: relative;
  display: flex; align-items: center;
  width: 100%;
  min-height: 44px;
  padding-left: 16px;
  color: inherit; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.list-row-inner.is-interactive { cursor: pointer; }
.list-row-inner.is-interactive:active { background: var(--row-pressed); }
@media (hover: hover) {
  .list-row-inner.is-interactive:hover { background: var(--fill-4); }
  .list-row-inner.is-interactive:active { background: var(--row-pressed); }
}
.list-row-inner:focus-visible { outline-offset: -3px; border-radius: var(--r-list); }
.list-row-leading { flex: none; display: flex; align-items: center; margin-right: 15px; }
.list-row.has-custom-leading .list-row-leading { margin-right: 12px; }
.list-row-main {
  flex: 1 1 auto; min-width: 0; align-self: stretch;
  display: flex; align-items: center; gap: 8px;
  min-height: 44px;
  padding: 11px 16px 11px 0;
}
.list-row + .list-row .list-row-main { box-shadow: inset 0 var(--hairline) 0 var(--sep); }
.list-row-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list-row-title {
  font-size: var(--fs-body); line-height: var(--lh-body); letter-spacing: var(--ls-body);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-row-title.is-multiline { white-space: normal; overflow-wrap: anywhere; }
.list-row-subtitle {
  font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--label-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-row-value {
  flex: none; max-width: 55%;
  font-size: var(--fs-body); line-height: var(--lh-body); color: var(--label-2);
  text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-row-value[class*="tone-"] { color: var(--tone-text); }
.list-row-accessory { flex: none; display: flex; align-items: center; gap: 8px; }
/* Disclosure chevron (disclosureChevron() in js/ui/list.js): one size, weight and colour on every tappable row. */
.disclosure-chevron, .list-row-chevron { flex: none; color: var(--label-3); }
.list-row-chevron { margin-left: 2px; margin-right: -3px; }
.list-row-check { flex: none; color: var(--accent); }
.list-row.is-destructive .list-row-title { color: var(--red-text); }
.list-row.is-disabled { opacity: .45; }
.list-row.is-large .list-row-main { min-height: 64px; padding-block: 10px; }
.list-row.is-large .list-row-inner { min-height: 64px; }

.icon-tile {
  width: var(--tile, 29px); height: var(--tile, 29px);
  border-radius: calc(var(--tile, 29px) * .23);
  display: grid; place-items: center; flex: none;
  color: #fff;
  background: var(--tile-bg, var(--blue));
}
.tile-blue { --tile-bg: var(--blue); }       .tile-green { --tile-bg: var(--green); }
.tile-red { --tile-bg: var(--red); }         .tile-orange { --tile-bg: var(--orange); }
.tile-yellow { --tile-bg: var(--yellow); }   .tile-indigo { --tile-bg: var(--indigo); }
.tile-teal { --tile-bg: var(--teal); }       .tile-pink { --tile-bg: var(--pink); }
.tile-purple { --tile-bg: var(--purple); }   .tile-gray { --tile-bg: var(--gray); }
.tile-mint { --tile-bg: var(--mint); }

/* ---------------------------------------------------------------- switch */
.switch { position: relative; display: inline-flex; flex: none; width: 51px; height: 31px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.switch-input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: relative; display: block;
  width: 51px; height: 31px; border-radius: 16px;
  background: var(--fill);
  transition: background-color 250ms linear;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 3px 1px rgba(0, 0, 0, .06);
  transition: transform 300ms var(--ease), width 200ms var(--ease);
}
.switch-input:checked + .switch-track { background: var(--green); }
.switch-accent .switch-input:checked + .switch-track { background: var(--accent); }
.switch-input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch-input:active + .switch-track .switch-thumb { width: 33px; }
.switch-input:checked:active + .switch-track .switch-thumb { transform: translateX(14px); }
.switch-input:focus-visible + .switch-track { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.switch-input:disabled { cursor: default; }
.switch-input:disabled + .switch-track { opacity: .45; }
/* Hover: a faint label-colour veil under the thumb (darkens in light, lifts in dark). */
.switch-track::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--label); opacity: 0; transition: opacity 150ms linear; }
@media (hover: hover) and (pointer: fine) {
  .switch-input:not(:disabled):hover + .switch-track::before { opacity: .06; }
}

/* ---------------------------------------------------------------- segmented control */
.segmented {
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  height: 32px; padding: 2px;
  border-radius: 9px;
  background: var(--fill-3);
  -webkit-tap-highlight-color: transparent;
}
.segmented-small { height: 28px; border-radius: 8px; }
/* Touch layouts: small segments grow to the iOS 32pt control height (items keep a 44pt hit area via hit slop). */
@media (max-width: 1023.98px), (pointer: coarse) {
  .segmented-small { height: 32px; }
}
.segmented-large { height: 36px; border-radius: 10px; }
.segmented-thumb {
  position: absolute; top: 2px; bottom: 2px; left: 2px;
  width: calc((100% - 4px) / var(--n));
  transform: translateX(calc(var(--i, 0) * 100%));
  border-radius: 7px;
  background: var(--seg-thumb);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04), 0 0 0 .5px rgba(0, 0, 0, .04);
  transition: transform 320ms var(--ease);
  z-index: 0;
}
.segmented-small .segmented-thumb { border-radius: 6px; }
.segmented-large .segmented-thumb { border-radius: 8px; }
.segmented-item {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 0; padding: 0 5px;
  font-size: 13px; font-weight: var(--w-medium); letter-spacing: -0.08px;
  color: var(--label);
  border-radius: 7px;
}
.segmented-large .segmented-item { font-size: 15px; }
.segmented-item + .segmented-item::before {
  content: ""; position: absolute; left: 0; top: 30%; bottom: 30%;
  width: 1px; background: var(--sep); opacity: .6;
  transition: opacity 200ms linear;
}
.segmented-item.is-selected::before, .segmented-item.is-selected + .segmented-item::before { opacity: 0; }
.segmented-label { display: inline-flex; flex-direction: column; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.segmented-label::after { content: attr(data-text); height: 0; visibility: hidden; font-weight: var(--w-semibold); overflow: hidden; }
.segmented-item.is-selected { font-weight: var(--w-semibold); }
.segmented-item:active .segmented-label { opacity: .55; }
@media (hover: hover) and (pointer: fine) {
  .segmented-item:not(.is-selected):hover { background: var(--fill-4); }
}
.segmented-badge { font-size: 12px; font-weight: var(--w-semibold); color: var(--label-2); font-variant-numeric: tabular-nums; }
.segmented-badge:empty { display: none; }
.segmented-item:focus-visible { outline-offset: -1px; }

/* ---------------------------------------------------------------- stepper */
.stepper { display: inline-flex; align-items: center; gap: 14px; }
.stepper-control { display: inline-flex; align-items: center; height: 32px; border-radius: 8px; background: var(--fill-3); flex: none; }
.stepper-btn { position: relative; width: 47px; height: 32px; display: grid; place-items: center; color: var(--label); border-radius: 8px; }
.stepper-btn::after { content: ""; position: absolute; inset: -7px 0; }
.stepper-btn:active:not(:disabled) { background: var(--fill-3); }
@media (hover: hover) and (pointer: fine) {
  .stepper-btn:hover:not(:disabled) { background: var(--fill-4); }
  .stepper-btn:active:not(:disabled) { background: var(--fill-3); }
}
.stepper-btn:disabled { color: var(--label-3); }
.stepper-sep { width: 1px; height: 18px; background: var(--sep); }
.stepper-value { font-size: 17px; font-weight: var(--w-semibold); text-align: right; min-width: 3ch; }

/* ---------------------------------------------------------------- slider */
.slider { display: flex; align-items: center; gap: 12px; min-width: 0; }
.slider-end { color: var(--label-2); flex: none; }
.slider-input {
  -webkit-appearance: none; appearance: none;
  flex: 1 1 auto; min-width: 0; height: 44px; margin: -6px 0;   /* 44pt touch height, 32pt of layout */
  background: transparent; cursor: pointer;
  --p: 50%;
}
.slider-input::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0 var(--p), var(--fill) var(--p) 100%);
}
.slider-input::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0 var(--p), var(--fill) var(--p) 100%);
}
.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 28px; margin-top: -12px; border-radius: 50%;
  background: #fff; border: 0;
  box-shadow: var(--shadow-thumb);
  transition: transform 150ms var(--ease);
}
.slider-input::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: #fff; box-shadow: var(--shadow-thumb);
}
.slider-input:active::-webkit-slider-thumb { transform: scale(1.06); }
.slider-input:focus-visible { outline: none; }
.slider-input:focus-visible::-webkit-slider-thumb { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.slider-input:focus-visible::-moz-range-thumb { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.slider-input:disabled { opacity: .45; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .slider-input:not(:disabled):hover::-webkit-slider-thumb { box-shadow: var(--shadow-thumb), 0 0 0 5px var(--fill-4); }
  .slider-input:not(:disabled):hover::-moz-range-thumb { box-shadow: var(--shadow-thumb), 0 0 0 5px var(--fill-4); }
}

/* ---------------------------------------------------------------- fields */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; line-height: 18px; font-weight: var(--w-medium); color: var(--label-2); padding: 0 4px; }
.field-control {
  display: flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 0 14px;
  border-radius: 12px;
  background: var(--field-bg, var(--fill-3));
  transition: box-shadow 150ms linear;
}
.field-control:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.field-input { flex: 1 1 auto; min-width: 0; height: 44px; font-size: var(--fs-body); color: var(--label); }
.field-input:focus-visible, .search-input:focus-visible { outline: none; }
textarea.field-input { height: auto; min-height: 88px; padding: 11px 0; resize: vertical; line-height: var(--lh-body); }
.field.is-multiline .field-control { align-items: flex-start; }
.field-affix { color: var(--label-2); flex: none; }
.field-affix:first-child { margin-right: -3px; }   /* "$39.95" reads as one value, like money everywhere else */
.field.is-multiline .field-affix { padding-top: 11px; }
.field-hint { font-size: 13px; line-height: 18px; color: var(--label-2); padding: 0 4px; text-wrap: pretty; }
.field-hint.is-error { color: var(--red-text); }
.field.has-error .field-control { box-shadow: 0 0 0 1.5px var(--red); }

.search-field {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 6px 0 8px;
  border-radius: 10px;
  background: var(--fill-3);
  color: var(--label-2);
}
.search-field:has(.search-input:focus-visible) { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.search-glass { flex: none; color: var(--label-2); }
.search-input { flex: 1 1 auto; min-width: 0; height: 36px; font-size: 17px; color: var(--label); -webkit-appearance: none; appearance: none; }
.search-input::-webkit-search-cancel-button, .search-input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.search-clear { display: none; width: 30px; height: 30px; place-items: center; color: var(--label-3); flex: none; --knockout: var(--bg-2); z-index: 2; }
.search-input { position: relative; z-index: 2; }
.search-field.has-value .search-clear { display: grid; }
.search-clear:active { opacity: .5; }
@media (hover: hover) and (pointer: fine) { .search-clear:hover { color: var(--label-2); } }
@media (min-width: 768px) { .search-input { font-size: 16px; } }

.inline-field { display: inline-flex; align-items: center; gap: 0; min-height: 32px; color: var(--label-2); font-size: var(--fs-body); cursor: text; }
.inline-input { width: 7em; text-align: right; font-size: var(--fs-body); color: var(--label-2); padding: 6px 0; }
/* With a prefix or suffix the input hugs its text (a hidden mirror sets the width), so "$0.30" and "1.75%"
   read as one value. The mirror inherits the field's font, including tabular figures. */
.inline-sizer { display: inline-grid; align-items: center; min-width: 1ch; }
.inline-sizer::after { content: attr(data-value) "\200B"; grid-area: 1 / 1; visibility: hidden; white-space: pre; padding-right: 2px; font: inherit; letter-spacing: inherit; }
.inline-sizer > .inline-input { grid-area: 1 / 1; width: 0; min-width: 100%; }   /* the mirror alone sizes the column */
.inline-field.has-prefix .inline-input { text-align: left; }
.inline-field.has-suffix:not(.has-prefix) .inline-sizer::after { padding: 0 0 0 2px; }   /* caret room away from the % */
.inline-input:focus { color: var(--label); }
.inline-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.inline-affix { color: var(--label-2); }

/* ---------------------------------------------------------------- chips */
.chips {
  display: flex; gap: 8px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 5px 0;           /* room for the chips' 44pt hit slop inside the scroller */
  margin-block: -3px;
}
.chips::-webkit-scrollbar { display: none; }
@media (max-width: 767.98px) {
  .chips { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter); }
}
.card .chips { margin-inline: 0; padding-inline: 0; }
/* Wider screens: there's room, so chips wrap instead of scrolling (no chip cut off mid-word). */
@media (min-width: 768px) {
  .chips { flex-wrap: wrap; overflow: visible; }
}
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: 17px;
  background: var(--chip-bg, var(--bg-2));
  color: var(--label);
  font-size: 15px; font-weight: var(--w-medium); letter-spacing: -0.15px;
  white-space: nowrap;
}
.card .chip, .sheet .chip { --chip-bg: var(--fill-3); }
.chip svg { color: var(--label-2); }
.chip.is-selected { background: var(--label); color: var(--bg-2); }
.chip.is-selected svg { color: inherit; }
@media (hover: hover) and (pointer: fine) {
  .chip:not(.is-selected):hover { background: color-mix(in srgb, var(--bg-2) 92%, var(--label)); }
  .card .chip:not(.is-selected):hover, .sheet .chip:not(.is-selected):hover { background: var(--fill-hover); }
}

/* ---------------------------------------------------------------- sheet */
.sheet-root { position: fixed; inset: 0; z-index: 100; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.sheet {
  position: absolute;
  display: flex; flex-direction: column;
  background: var(--bg);
  color: var(--label);
  outline: none;
  overflow: hidden;
}
.sheet.is-phone {
  left: 0; right: 0; bottom: 0;
  max-height: calc(100dvh - var(--safe-top) - 10px);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--shadow-sheet);
  padding-bottom: var(--safe-bottom);
  will-change: transform;
}
.sheet.is-phone.detent-large { height: calc(100dvh - var(--safe-top) - 10px); }
.sheet.is-phone.detent-medium { height: min(calc(100dvh - var(--safe-top) - 10px), max(52dvh, 380px)); }
.sheet-root.is-modal { display: flex; align-items: center; justify-content: center; padding: 32px 24px; }
.sheet.is-modal {
  position: relative;
  width: min(560px, 100%);
  max-height: min(86dvh, 860px);
  border-radius: 16px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .28), 0 0 0 .5px rgba(0, 0, 0, .1);
}
.sheet.is-modal.is-wide { width: min(720px, 100%); }
.sheet.is-modal.detent-large { height: min(86dvh, 860px); }
.sheet-grabber {
  position: absolute; top: 5px; left: 50%; z-index: 3;
  width: 36px; height: 5px; margin-left: -18px; border-radius: 3px;
  background: var(--label-3);
}
.sheet-header {
  flex: none; position: relative; z-index: 2;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 4px;
  min-height: 56px; padding: 10px 8px 2px;
  transition: box-shadow 150ms linear;
}
/* Scroll edges: a hairline under the header once content scrolls beneath it, and a soft fade at the bottom
   while more content waits below (so a cut-off total never looks like the end). */
.sheet.is-scrolled .sheet-header { box-shadow: 0 var(--hairline) 0 var(--sep); }
.sheet.has-more .sheet-body {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), rgba(0, 0, 0, .15));
  mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), rgba(0, 0, 0, .15));
}
.sheet.is-modal .sheet-header { min-height: 54px; padding: 4px 10px 0; }
.sheet-header-leading { justify-self: start; display: flex; }
.sheet-header-trailing { justify-self: end; display: flex; }
.sheet-title {
  font-size: 17px; line-height: 22px; font-weight: var(--w-semibold); letter-spacing: -0.2px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62vw;
}
.sheet-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; padding: 0 10px;
  font-size: 17px; letter-spacing: -0.2px; color: var(--accent-text);
  border-radius: 10px;
}
.sheet-btn.is-done { font-weight: var(--w-semibold); }
.sheet-btn.is-destructive { color: var(--red-text); }
.sheet-btn:active { opacity: .45; }
.sheet-btn:disabled { color: var(--label-3); cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .sheet-btn:hover:not(:disabled) { background: var(--fill-4); }
  .sheet-close:hover { background: var(--fill-hover); }
}
.sheet-btn .spinner { color: var(--label-2); }
.sheet-close {
  position: relative;
  width: 30px; height: 30px; margin: 7px 8px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--fill-3); color: var(--label-2);
}
.sheet-close::before { content: ""; position: absolute; inset: -7px; }
.sheet-close:active { opacity: .5; }
.sheet-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px 28px;
}
.sheet.is-modal .sheet-body { padding: 8px 24px 28px; }
/* Toasts raised while this sheet is on top (js/ui/toast.js): a row under the body, so the body shrinks rather than being
   covered. Empty → takes no room. */
.sheet-toast-slot {
  flex: none; position: relative; z-index: 2;
  display: flex; justify-content: center;
  padding: 6px 12px 12px;
}
.sheet-toast-slot:empty { display: none; }
.sheet.is-modal .sheet-toast-slot { padding: 8px 16px 16px; }
.sheet-toast-slot .toast { box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 20px rgba(0, 0, 0, .12); }

/* ---------------------------------------------------------------- alert + action sheet */
.alert-root { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 24px; }
.alert-root.is-bottom { align-items: flex-end; padding: 8px 8px calc(8px + var(--safe-bottom)); }
.alert-backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.alert {
  position: relative;
  width: 270px; max-width: 100%;
  border-radius: 14px; overflow: hidden;
  background: var(--material-alert);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  text-align: center;
  outline: none;
  box-shadow: var(--shadow-float);
}
.alert.is-menu { width: 300px; }
.alert-content { padding: 19px 16px 18px; }
.alert-title { font-size: 17px; line-height: 22px; font-weight: var(--w-semibold); letter-spacing: -0.2px; text-wrap: balance; }
.alert-message { margin-top: 3px; font-size: 13px; line-height: 18px; color: var(--label); text-wrap: pretty; }
.alert-actions { display: flex; box-shadow: inset 0 var(--hairline) 0 var(--sep); }
.alert-actions.is-column { flex-direction: column; }
.alert-btn {
  flex: 1 1 0; min-height: 44px; padding: 0 8px;
  display: grid; place-items: center;
  font-size: 17px; letter-spacing: -0.2px; color: var(--accent-text);
}
.alert-actions.is-row .alert-btn + .alert-btn { box-shadow: inset var(--hairline) 0 0 var(--sep); }
.alert-actions.is-column .alert-btn + .alert-btn { box-shadow: inset 0 var(--hairline) 0 var(--sep); }
.alert-btn.is-cancel, .alert-btn.is-preferred { font-weight: var(--w-semibold); }
.alert-btn.is-destructive { color: var(--red-text); }
.alert-btn:active { background: var(--highlight); }
@media (hover: hover) and (pointer: fine) { .alert-btn:hover { background: var(--fill-4); } }
.alert-btn:focus-visible { outline: none; background: var(--highlight); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent); }

.action-sheet { position: relative; width: 100%; max-width: 500px; display: flex; flex-direction: column; gap: 8px; outline: none; }
.action-sheet-group {
  border-radius: 14px; overflow: hidden;
  background: var(--material-alert);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
}
.action-sheet-group.is-cancel { background: var(--bg-elevated); }
.action-sheet-head { padding: 14px 16px 13px; text-align: center; }
.action-sheet-title { font-size: 13px; line-height: 18px; font-weight: var(--w-semibold); color: var(--label-2); }
.action-sheet-message { font-size: 13px; line-height: 18px; color: var(--label-2); }
.action-sheet-btn { width: 100%; min-height: 57px; font-size: 20px; letter-spacing: -0.3px; box-shadow: inset 0 var(--hairline) 0 var(--sep); }
.action-sheet-group > .action-sheet-btn:first-child, .action-sheet-group.is-cancel .action-sheet-btn { box-shadow: none; }

/* ---------------------------------------------------------------- toast
   Bottom centre, above the tab bar (phone/tablet) or the bottom of the content column (sidebar layout), so it
   never covers the nav bar or its back button. Views with their own sticky bottom bar can lift it with
   --toast-offset (set on :root while mounted).
   Stacking (iOS): sheets 100 < the page's toast region 110 < alerts 120 < popovers 130. A toast raised while a sheet
   is open sits in that sheet's .sheet-toast-slot instead (under its scrolling body, which gives up the room), so it
   never covers sheet controls; an alert's backdrop dims and blocks a toast like everything else. */
.toast-region {
  position: fixed; left: var(--sidebar-w); right: 0; z-index: 110;
  bottom: calc(var(--tabbar-space) + var(--toast-offset, 0px) + 12px);
  display: flex; justify-content: center;
  padding: 0 max(12px, var(--safe-right)) 0 max(12px, var(--safe-left));
  pointer-events: none;
}
@media (min-width: 1024px) { .toast-region { bottom: calc(var(--tabbar-space) + var(--toast-offset, 0px) + 24px); } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  min-height: 50px; max-width: min(460px, 100%);
  padding: 8px 18px 8px 14px;
  border-radius: 25px;
  background: var(--material-toast);
  -webkit-backdrop-filter: var(--material-filter);
  backdrop-filter: var(--material-filter);
  box-shadow: var(--shadow-float);
  font-size: 15px; line-height: 20px; font-weight: var(--w-semibold); letter-spacing: -0.15px;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.toast:focus-within { box-shadow: var(--shadow-float), 0 0 0 2.5px color-mix(in srgb, var(--accent) 55%, transparent); }
.toast:has(.toast-action) { padding-right: 8px; }
.toast-icon { display: grid; place-items: center; color: var(--label-2); flex: none; --knockout: var(--bg-2); }
.toast.tone-success .toast-icon { color: var(--green); }
.toast.tone-error .toast-icon { color: var(--red); }
.toast.tone-warning .toast-icon { color: var(--orange); }
.toast.tone-info .toast-icon { color: var(--accent); }
.toast-message { flex: 1 1 auto; min-width: 0; text-wrap: pretty; }
.toast-action {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px;
  background: var(--accent-tint); color: var(--accent-text);
  font-size: 15px; font-weight: var(--w-semibold);
}
.toast-action:active { opacity: .6; }
.toast-action:focus-visible { outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .toast-action:hover { background: var(--accent-tint-hover); } }

/* ---------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  height: 22px; padding: 0 8px;
  border-radius: 11px;
  font-size: 12px; line-height: 1; font-weight: var(--w-semibold); letter-spacing: 0;
  white-space: nowrap;
  vertical-align: middle;
}
.pill-small { height: 18px; padding: 0 6px; font-size: 11px; border-radius: 9px; gap: 3px; }
.pill-large { height: 28px; padding: 0 12px; font-size: 13px; border-radius: 14px; }
.pill-tinted { color: var(--tone-text); background: color-mix(in srgb, var(--tone) 15%, transparent); }
.pill-filled { color: #fff; background: color-mix(in srgb, var(--tone) 80%, #000); }   /* a step darker: white text ≥ 4.8:1 */
.pill-plain { color: var(--tone-text); background: none; padding: 0; height: auto; }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tone); }

/* ---------------------------------------------------------------- card */
.card {
  position: relative;
  min-width: 0;
  background: var(--bg-2);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  color: inherit; text-align: left;
}
a.card, button.card { display: block; }
button.card { width: 100%; font: inherit; }
.card.is-padded { padding: 16px; }
@media (min-width: 768px) { .card.is-padded { padding: 20px; } }
.card.is-interactive { cursor: pointer; }
.card.is-interactive.pressable:active { transform: scale(.985); opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .card.is-interactive:hover, .stat.is-interactive:hover { background: color-mix(in srgb, var(--bg-2) 96%, var(--label)); }
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px; margin-bottom: 12px; }
.card-heading { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-headline); line-height: var(--lh-headline); font-weight: var(--w-semibold); }
.card-heading[class*="tone-"] { color: var(--tone-text); }
.card-heading[class*="tone-"] svg { color: var(--tone); }
.card-title { font: inherit; letter-spacing: -0.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-chevron { color: var(--label-3); margin-left: 2px; }
.card-action { display: inline-flex; align-items: center; gap: 3px; flex: none; font-size: 15px; color: var(--accent-text); white-space: nowrap; }
.card-action svg { color: var(--accent-text); opacity: .7; }
.card-action:active { opacity: .45; }
.card-subtitle { margin: -6px 0 12px; font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--label-2); text-wrap: pretty; }
.card-footer { margin-top: 14px; }
/* A list or media flush with the card edges: put .card-flush on the child. */
.card.is-padded > .card-body > .card-flush { margin-inline: -16px; }
@media (min-width: 768px) { .card.is-padded > .card-body > .card-flush { margin-inline: -20px; } }

/* ---------------------------------------------------------------- stat tile */
.stat {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
  padding: 13px 15px 14px;
  border-radius: 16px;
  background: var(--bg-2);
  color: inherit; text-align: left;
  position: relative;
}
button.stat { width: 100%; font: inherit; }
.stat.is-interactive { cursor: pointer; transition: background-color var(--dur-fast) linear, transform var(--dur-press) var(--ease); }
.stat.is-interactive:active { transform: scale(.97); }
.stat-label { display: flex; align-items: center; gap: 5px; min-height: 18px; font-size: 13px; line-height: 18px; font-weight: var(--w-semibold); color: var(--label-2); }
.stat-label[class*="tone-"] { color: var(--tone-text); }
.stat-label[class*="tone-"] svg { color: var(--tone); }
.stat-label .stat-info { margin: -10px -11px -10px auto; }
.stat-value {
  margin-top: 3px;
  font-family: var(--font-rounded);
  font-size: 28px; line-height: 34px; font-weight: var(--w-bold); letter-spacing: -0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-sub { font-size: 13px; line-height: 18px; color: var(--label-2); }
.stat-sub[class*="tone-"] { color: var(--tone-text); }
@media (max-width: 380px) { .stat-value { font-size: 24px; line-height: 30px; } .stat { padding-inline: 13px; } }

/* ---------------------------------------------------------------- empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; max-width: 440px; margin: 0 auto;
  padding: 56px 24px;
}
.empty.is-compact { padding: 28px 16px; }
.empty-icon { color: var(--label-3); margin-bottom: 10px; }
.empty-title { font-size: 20px; line-height: 25px; font-weight: var(--w-semibold); letter-spacing: -0.3px; text-wrap: balance; }
.empty-message { font-size: var(--fs-subhead); line-height: var(--lh-subhead); color: var(--label-2); text-wrap: pretty; }
.empty-action { margin-top: 14px; }

/* ---------------------------------------------------------------- progress steps */
.steps-list { display: flex; flex-direction: column; }
.step { display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 6px 0; }
.step-indicator { width: 24px; height: 24px; display: grid; place-items: center; flex: none; --knockout: var(--bg-2); }
.step-dot { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--fill); }
.step-text { display: flex; flex-direction: column; min-width: 0; }
.step-label { font-size: var(--fs-body); line-height: var(--lh-body); transition: color 200ms linear; }
.step.is-pending .step-label { color: var(--label-2); }   /* readable plan; the hollow dot says "not started" */
.step.is-active .step-label { color: var(--label); font-weight: var(--w-semibold); }
.step.is-done .step-label { color: var(--label-2); }
.step.is-done .step-indicator { color: var(--green); animation: step-pop 420ms var(--ease-out); }
.step.is-failed .step-indicator { color: var(--red); }
.step.is-failed .step-label { color: var(--label); }
.step-note { font-size: 13px; line-height: 18px; color: var(--red-text); }
.step-note:empty { display: none; }
@keyframes step-pop { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.14); opacity: 1; } 100% { transform: scale(1); } }

/* ---------------------------------------------------------------- meter */
.meter { --meter: var(--accent); }
.meter[data-tone="green"] { --meter: var(--green); }
.meter[data-tone="orange"] { --meter: var(--orange); }
.meter[data-tone="red"] { --meter: var(--red); }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
.meter-label { color: var(--label-2); }
.meter-value { font-weight: var(--w-semibold); white-space: nowrap; }
.meter-track { display: block; height: 8px; border-radius: 4px; overflow: hidden; background: color-mix(in srgb, var(--meter) 18%, transparent); }
.meter-fill { display: block; height: 100%; border-radius: 4px; background: var(--meter); transition: width 600ms var(--ease), background-color var(--dur) linear; }
/* kind: 'progress' at 100%: green bar, a checkmark and green text (success, not a warning). */
.meter-check { display: inline-flex; vertical-align: -3px; margin-right: 5px; color: var(--green); }
.meter-check[hidden] { display: none; }
.meter.is-complete .meter-value { color: var(--green-text); }
.meter.is-complete .meter-check svg { animation: step-pop 420ms var(--ease-out); }

/* ---------------------------------------------------------------- skeleton */
.skeleton { display: block; position: relative; overflow: hidden; background: var(--skeleton); border-radius: 6px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent);
  animation: parcel-shimmer 1.4s ease-in-out infinite;
}
@keyframes parcel-shimmer { to { transform: translateX(100%); } }
.skeleton-row .list-row-main { min-height: 60px; }

/* ---------------------------------------------------------------- charts */
.bar-chart { position: relative; width: 100%; outline: none; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.bar-chart:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 6px; border-radius: 8px; }
.bar-chart-svg { display: block; overflow: visible; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-zero { stroke: var(--label-3); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis { fill: var(--chart-axis); font-family: var(--font); font-size: 11px; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.chart-col { transition: opacity 150ms linear; }
.chart-col.is-dim { opacity: .28; }
.chart-col.is-partial path { fill-opacity: .5; }
.chart-tip {
  position: absolute; z-index: 3; top: 0; left: 0;
  padding: 6px 10px 7px;
  border-radius: 10px;
  background: var(--bg-3);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  white-space: nowrap;
  pointer-events: none;
}
.chart-tip-value { font-family: var(--font-rounded); font-size: 17px; line-height: 22px; font-weight: var(--w-bold); }
.chart-tip-label { font-size: 12px; line-height: 16px; color: var(--label-2); }
.sparkline { display: block; overflow: visible; flex: none; }

.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring-svg { position: absolute; inset: 0; overflow: visible; }
.ring.is-animating .ring-arc { transition: stroke-dashoffset 1100ms var(--ease-out); }
.ring-lap { filter: drop-shadow(0 0 3px rgba(0, 0, 0, .35)); }
.ring-center { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 70%; }
.ring-label { font-family: var(--font-rounded); font-weight: var(--w-bold); font-size: calc(var(--ring-size) * .17); line-height: 1.1; letter-spacing: -0.3px; }
.ring-sublabel { font-size: max(11px, calc(var(--ring-size) * .095)); line-height: 1.2; color: var(--label-2); }
.ring-label:empty, .ring-sublabel:empty { display: none; }

/* ---------------------------------------------------------------- info button + popover */
.info-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; margin: -9px;          /* 18px footprint; the hit slop makes the target 44×44 */
  border-radius: 50%;
  color: var(--accent-text);
  transition: background-color var(--dur-fast) linear;
}
.info-btn:active svg { opacity: .45; }
@media (hover: hover) and (pointer: fine) { .info-btn:hover { background: var(--fill-4); } }
.popover {
  position: fixed; z-index: 130;
  padding: 14px 16px 15px;
  border-radius: 14px;
  background: var(--bg-elevated);
  color: var(--label);
  box-shadow: var(--shadow-float);
  outline: none;
  transform-origin: top center;
}
.popover.is-above { transform-origin: bottom center; }
.popover-title { font-size: 15px; line-height: 20px; font-weight: var(--w-semibold); margin-bottom: 3px; text-wrap: balance; }
.popover-text { font-size: 15px; line-height: 20px; color: var(--label-2); text-wrap: pretty; }
.popover-arrow {
  position: absolute; top: -6px;
  width: 14px; height: 14px; margin-left: -7px;
  background: var(--bg-elevated);
  transform: rotate(45deg);
  border-radius: 3px 0 0 0;
}
.popover.is-above .popover-arrow { top: auto; bottom: -6px; border-radius: 0 0 3px 0; }

/* ---------------------------------------------------------------- values */
.money { white-space: nowrap; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: var(--w-medium); }
.delta-suffix { color: var(--label-2); font-weight: var(--w-regular); white-space: pre; }

/* ---------------------------------------------------------------- step indicator (js/ui/steps.js)
   A caption ("Step 2 of 5") over a row of 4px capsules: finished + current = accent, the rest grey. The capsule of the
   step you arrive at fills left to right (instant under reduced motion). */
.flow-steps { min-width: 0; }
.flow-steps.labels-auto { container-type: inline-size; }
.flow-steps-caption {
  margin: 0 0 8px;
  font-size: 13px; line-height: 18px; font-weight: var(--w-semibold); color: var(--label-2);
  font-variant-numeric: tabular-nums;
}
.flow-steps-list { display: flex; gap: 6px; }
.flow-step { flex: 1 1 0; min-width: 0; display: flex; }
.flow-step-hit { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: 100%; min-width: 0; border-radius: 2px; }
button.flow-step-hit { cursor: pointer; -webkit-tap-highlight-color: transparent; text-align: inherit; }
button.flow-step-hit::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: max(100%, var(--hit)); transform: translateY(-50%); }
button.flow-step-hit:focus-visible { outline-offset: 5px; }
/* Step names under the capsules (tablet and desktop widths): finished = accent like a link, current = bold, next = grey. */
.flow-step-name {
  display: none;
  font-size: 12px; line-height: 16px; font-weight: var(--w-medium); color: var(--label-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flow-steps.labels-on .flow-step-name { display: block; }
@container (min-width: 400px) { .flow-steps.labels-auto .flow-step-name { display: block; } }
.flow-step.is-current .flow-step-name { color: var(--label); font-weight: var(--w-semibold); }
button.flow-step-hit .flow-step-name { color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) {
  button.flow-step-hit:hover .flow-step-name { text-decoration: underline; text-underline-offset: 2px; }
}
.flow-step-bar { position: relative; display: block; width: 100%; height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.flow-step-bar::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left center;
  transition: transform var(--dur-slow) var(--ease);
}
.flow-step.is-done .flow-step-bar::before, .flow-step.is-current .flow-step-bar::before { transform: none; }
.flow-step.is-arriving .flow-step-bar::before { transform: scaleX(0); transition: none; }
button.flow-step-hit:active .flow-step-bar { opacity: .5; }
@media (hover: hover) and (pointer: fine) { button.flow-step-hit:hover .flow-step-bar::before { opacity: .72; } }

/* ---------------------------------------------------------------- device frame (js/ui/device.js)
   Mirrors the storefront preview's frame in css/brand.css (phone 414 design px incl. bezel, window 1200), so a page
   preview and the homepage preview look like the same device. Content inside is normal size (not scaled). */
.device { container-type: inline-size; width: 100%; min-width: 0; margin-inline: auto; color-scheme: light; }
.device--phone { max-width: var(--device-max, 360px); }
.device--desktop { max-width: var(--device-max, none); }
.device-frame { --u: calc(100cqw / var(--device-w, 414)); position: relative; }
.device--phone .device-frame {
  --device-w: 414;
  padding: calc(var(--u) * 12);
  border-radius: calc(var(--u) * 62);
  background: linear-gradient(145deg, #3A3A3C, #1C1C1E 40%, #0B0B0C);
  box-shadow: inset 0 0 0 calc(var(--u) * 2) #48484A, 0 calc(var(--u) * 12) calc(var(--u) * 40) rgba(0, 0, 0, .18);
}
.device--desktop .device-frame {
  --device-w: 1200;
  border-radius: max(8px, calc(var(--u) * 12));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .12), 0 calc(var(--u) * 16) calc(var(--u) * 48) rgba(0, 0, 0, .16);
}
.device-screen {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--device-bg, #FFFFFF); color: var(--device-ink, #1D1D1F);
}
.device--phone .device-screen { border-radius: calc(var(--u) * 50); }
.device--desktop .device-screen { border-radius: max(8px, calc(var(--u) * 12)); }
.device-status {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(var(--u) * 50);
  padding: 0 calc(var(--u) * 32) 0 calc(var(--u) * 42);
  background: #F6F6F8; color: #000;
}
.device-status svg { width: calc(var(--u) * 68); height: calc(var(--u) * 12); }
.device-time { font: 600 calc(var(--u) * 16) / 1 var(--font); letter-spacing: -.01em; }
.device-island {
  position: absolute; left: 50%; top: calc(var(--u) * 12);
  width: calc(var(--u) * 118); height: calc(var(--u) * 34);
  border-radius: 999px; background: #000;
  transform: translateX(-50%);
}
.device-urlbar { padding: calc(var(--u) * 4) calc(var(--u) * 16) calc(var(--u) * 10); background: #F6F6F8; border-bottom: 1px solid rgba(0, 0, 0, .08); }
.device-address {
  display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * 6);
  min-width: 0; height: calc(var(--u) * 40);
  border-radius: calc(var(--u) * 12);
  background: rgba(118, 118, 128, .12); color: #000;
  font: 500 calc(var(--u) * 15) / 1 var(--font); letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden;
}
.device-address svg { width: calc(var(--u) * 10); height: calc(var(--u) * 12); flex: none; color: rgba(60, 60, 67, .7); }
.device-address span { overflow: hidden; text-overflow: ellipsis; }
.device-chrome {
  display: grid; grid-template-columns: 1fr minmax(0, calc(var(--u) * 480)) 1fr; align-items: center;
  height: max(28px, calc(var(--u) * 44));
  padding: 0 max(10px, calc(var(--u) * 16));
  background: #EEEEF0; border-bottom: 1px solid rgba(0, 0, 0, .1);
}
.device-dots { display: flex; gap: max(5px, calc(var(--u) * 8)); }
.device-dots i { display: block; width: max(8px, calc(var(--u) * 12)); height: max(8px, calc(var(--u) * 12)); border-radius: 50%; background: #D1D1D6; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); }
.device-chrome .device-address svg { width: max(8px, calc(var(--u) * 10)); height: max(10px, calc(var(--u) * 12)); }
.device-chrome .device-address {
  height: max(20px, calc(var(--u) * 28)); border-radius: max(5px, calc(var(--u) * 8));
  background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
  font-size: max(11px, calc(var(--u) * 13));
}
.device-viewport {
  position: relative;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(0, 0, 0, .25) transparent;
  background: var(--device-bg, #FFFFFF); color: var(--device-ink, #1D1D1F);
  font-size: 15px; line-height: 1.45; letter-spacing: -0.1px;
  overflow-wrap: break-word;
}
.device--phone .device-viewport { height: var(--device-h, calc(var(--u) * 700)); }
.device--desktop .device-viewport { height: var(--device-h, max(320px, calc(var(--u) * 700))); }
.device-viewport.is-full { height: auto; overflow: visible; }
.device-viewport:focus { outline: none; }
.device-viewport:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .device--phone .device-frame { box-shadow: inset 0 0 0 calc(var(--u) * 2) #48484A, 0 0 0 1px rgba(255, 255, 255, .12); }
  :root:not([data-theme="light"]) .device--desktop .device-frame { box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }
}
:root[data-theme="dark"] .device--phone .device-frame { box-shadow: inset 0 0 0 calc(var(--u) * 2) #48484A, 0 0 0 1px rgba(255, 255, 255, .12); }
:root[data-theme="dark"] .device--desktop .device-frame { box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }

/* ---------------------------------------------------------------- checklist (js/ui/checklist.js) */
.check-progress { font-size: 13px; line-height: 18px; color: var(--label-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.check-progress.is-done { color: var(--green-text); font-weight: var(--w-semibold); }
.check-row {
  position: relative;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px 14px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-press) linear;
}
.check-row.is-locked { cursor: default; }
.check-row + .check-row::before { content: ""; position: absolute; top: 0; right: 0; left: 54px; height: var(--hairline); background: var(--sep); }
.check-row:not(.is-locked):active { background: var(--row-pressed); }
@media (hover: hover) and (pointer: fine) {
  .check-row:not(.is-locked):hover { background: var(--fill-4); }
  .check-row:not(.is-locked):active { background: var(--row-pressed); }
}
/* The tick: a full 44pt button around a 28px circle; negative margins keep the circle where it sits. */
.check-btn {
  position: relative; flex: none;
  display: grid; place-items: center;
  width: var(--hit); height: var(--hit);
  margin: -11px -8px -8px;
  border-radius: 50%;
  color: var(--label-2);
  -webkit-tap-highlight-color: transparent;
}
.check-btn:focus-visible { outline-offset: -5px; }
.check-circle {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--label-3);
  transition: background-color var(--dur-fast) linear, box-shadow var(--dur-fast) linear;
}
.check-num, .check-tick { grid-area: 1 / 1; }
.check-num { font-family: var(--font-rounded); font-size: 14px; line-height: 1; font-weight: var(--w-semibold); font-variant-numeric: tabular-nums; }
.check-tick { color: #fff; opacity: 0; transform: scale(.5); }
.check-row.is-done .check-circle { background: var(--green); box-shadow: none; }
.check-row.is-done .check-num { opacity: 0; }
.check-row.is-done .check-tick { opacity: 1; transform: none; }
/* Locked (Parcel sets it): a dashed circle while it waits, so it never reads as a box to tick. */
.check-row.is-locked:not(.is-done) .check-circle { box-shadow: none; border: 1.5px dashed var(--label-3); }
.check-row.just-done .check-circle { animation: check-pop 420ms var(--ease-out); }
.check-row.just-done .check-tick { transition: opacity 120ms linear, transform 380ms var(--ease-out); }
@keyframes check-pop { 0% { transform: scale(.82); } 55% { transform: scale(1.12); } 100% { transform: scale(1); } }
.check-body { flex: 1 1 auto; min-width: 0; }
.check-title {
  font-size: var(--fs-headline); line-height: var(--lh-headline); letter-spacing: var(--ls-headline); font-weight: var(--w-semibold);
  transition: color var(--dur-fast) linear;
}
.check-row.is-done .check-title { color: var(--label-2); }
.check-opt {
  display: inline-block; vertical-align: 2px;
  margin-left: 8px; padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--fill-3); color: var(--label-2);
  font-size: 11px; line-height: 14px; font-weight: var(--w-semibold); letter-spacing: 0;
}
.check-text { margin-top: 3px; font-size: var(--fs-subhead); line-height: var(--lh-subhead); letter-spacing: var(--ls-subhead); color: var(--label-2); text-wrap: pretty; }
.check-meta { margin-top: 4px; font-size: 13px; line-height: 18px; color: var(--label-2); font-weight: var(--w-medium); }
.check-extras { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.check-links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; }
.check-link {
  display: inline-flex; align-items: center; gap: 3px;
  min-height: 32px;
  font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: var(--w-medium);
  color: var(--accent-text);
  transition: opacity var(--dur-press) linear;
}
.check-link:active { opacity: .45; }
@media (hover: hover) and (pointer: fine) { .check-link:hover { text-decoration: underline; text-underline-offset: 2px; } }

/* ---------------------------------------------------------------- choice cards (js/ui/choice.js) */
.choice-wrap { container-type: inline-size; min-width: 0; }
.choice-group { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); align-items: stretch; }
@container (min-width: 520px) { .choice-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 720px) { .choice-cols-auto, .choice-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.choice {
  position: relative; min-width: 0;
  padding: 16px;
  border-radius: var(--r-card);
  background: var(--bg-2);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease), background-color var(--dur-fast) linear;
}
.choice:active { transform: scale(.985); }
.choice:focus-visible { outline-offset: 4px; }
.choice.is-selected { box-shadow: 0 0 0 2px var(--accent); }
.choice.is-disabled { cursor: default; opacity: .5; }
.choice.is-disabled:active { transform: none; }
@media (hover: hover) and (pointer: fine) {
  .choice:not(.is-disabled):hover { background: color-mix(in srgb, var(--bg-2) 96%, var(--label)); }
}
.choice-mark {
  position: absolute; top: 14px; right: 14px;
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--label-3);
  color: #fff;
  transition: background-color var(--dur-fast) linear, box-shadow var(--dur-fast) linear;
}
.choice-mark svg { opacity: 0; transform: scale(.5); transition: opacity 120ms linear, transform 300ms var(--ease-out); }
.choice.is-selected .choice-mark { background: var(--accent-fill); box-shadow: none; }
.choice.is-selected .choice-mark svg { opacity: 1; transform: none; }
.choice-badge {
  display: inline-flex; align-items: center;
  height: 22px; margin-bottom: 10px; padding: 0 9px;
  border-radius: var(--r-full);
  background: var(--accent-tint); color: var(--accent-text);
  font-size: 12px; line-height: 1; font-weight: var(--w-semibold);
}
.choice-body { min-width: 0; }
/* The name line keeps clear of the check (give it .choice-title); with a badge on top, the badge row already does. */
.choice-mark + .choice-body .choice-title { padding-right: 32px; }
@media (min-width: 768px) { .choice { padding: 20px; } .choice-mark { top: 18px; right: 18px; } }

/* ---------------------------------------------------------------- score breakdown (js/ui/score.js) */
.score-parts { display: flex; flex-direction: column; min-width: 0; }
.score-part { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.score-part-icon { flex: none; margin-top: 10px; color: var(--green); --knockout: var(--bg-2); }
.score-part.is-meh .score-part-icon { color: var(--orange); }
.score-part-main { flex: 1 1 auto; min-width: 0; padding: 10px 0 12px; }
.score-part + .score-part .score-part-main { box-shadow: inset 0 var(--hairline) 0 var(--sep); }
.score-part:first-child .score-part-main { padding-top: 8px; }
.score-part:first-child .score-part-icon { margin-top: 8px; }
.score-part:last-child .score-part-main { padding-bottom: 0; }
.score-part-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.score-part-label { min-width: 0; font-size: var(--fs-subhead); line-height: 20px; font-weight: var(--w-semibold); }
.score-part-pts { flex: none; font-size: var(--fs-footnote); color: var(--label-2); font-weight: var(--w-medium); font-variant-numeric: tabular-nums; }
.score-part-bar { display: block; height: 4px; margin: 6px 0 7px; border-radius: 2px; overflow: hidden; background: var(--fill-3); }
.score-part-bar > span { display: block; height: 100%; width: calc(var(--f) * 100%); border-radius: 2px; background: var(--green); }
.score-part.is-meh .score-part-bar > span { background: var(--orange); }
.score-part-text { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-2); text-wrap: pretty; }
.score-part-source { margin-top: 2px; font-size: var(--fs-caption); line-height: var(--lh-caption); color: var(--label-2); }
/* Compact (inside small cards): label + points on one line, the bar under it, tight rows, no hairlines. */
.score-parts.is-compact { gap: 8px; }
.score-parts.is-compact .score-part-main { padding: 0; box-shadow: none; }
.score-parts.is-compact .score-part-label { font-size: var(--fs-footnote); line-height: 18px; font-weight: var(--w-medium); color: var(--label-2); }
.score-parts.is-compact .score-part-bar { margin: 4px 0 0; }

/* ---------------------------------------------------------------- copy button (js/ui/clipboard.js) */
.copy-btn {
  position: relative; flex: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  color: var(--accent-text);
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-fast) linear, color var(--dur-fast) linear, opacity var(--dur-press) linear;
}
.copy-btn:active { opacity: .55; }
.copy-btn.is-capsule {
  min-width: 76px; height: 30px; padding: 0 12px;
  border-radius: 15px;
  background: var(--accent-tint);
  font-size: 14px; line-height: 1; font-weight: var(--w-semibold); white-space: nowrap;
}
.copy-btn.is-capsule::after { content: ""; position: absolute; z-index: 1; inset: min(0px, calc(50% - var(--hit) / 2)); }
.copy-btn.is-icon { width: var(--hit); height: var(--hit); border-radius: 50%; }
.copy-glyph { display: grid; place-items: center; }
.copy-btn.is-copied { color: var(--green-text); }
.copy-btn.is-capsule.is-copied { background: color-mix(in srgb, var(--green) 15%, transparent); }
.copy-btn.is-failed { color: var(--red-text); }
.copy-btn.is-capsule.is-failed { background: color-mix(in srgb, var(--red) 12%, transparent); }
@media (hover: hover) and (pointer: fine) {
  .copy-btn.is-capsule:hover { background: var(--accent-tint-hover); }
  .copy-btn.is-icon:hover { background: var(--fill-4); }
}

/* ---------------------------------------------------------------- copy block (js/ui/clipboard.js copyBlock) */
.copy-block { min-width: 0; padding: 12px 14px 14px; border-radius: var(--r-lg); background: var(--bg-2); }
.card .copy-block, .sheet .card .copy-block { background: var(--bg-3); }
.copy-block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; margin-bottom: 6px; }
.copy-block-title { min-width: 0; font-size: 13px; line-height: 18px; font-weight: var(--w-semibold); color: var(--label-2); }
.copy-block-text {
  font-size: var(--fs-subhead); line-height: var(--lh-subhead); letter-spacing: var(--ls-subhead);
  white-space: pre-wrap; overflow-wrap: anywhere;
  -webkit-user-select: text; user-select: text;
}
.copy-block-text.is-mono { font-family: var(--font-mono); font-size: 14px; line-height: 20px; letter-spacing: 0; }
.copy-block-text.is-collapsed {
  max-height: calc(var(--lines, 8) * 1lh); overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2lh), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 2lh), transparent);
}
.copy-block-more {
  position: relative; display: inline-flex; align-items: center; min-height: 30px; margin-top: 4px;
  color: var(--accent-text); font-size: var(--fs-subhead); font-weight: var(--w-medium);
}
.copy-block-more::after { content: ""; position: absolute; inset: min(0px, calc(50% - var(--hit) / 2)); }
.copy-block-more:active { opacity: .45; }
@media (hover: hover) and (pointer: fine) { .copy-block-more:hover { text-decoration: underline; text-underline-offset: 2px; } }
.copy-block-note { margin-top: 8px; font-size: 13px; line-height: 18px; color: var(--label-2); text-wrap: pretty; }

/* ---------------------------------------------------------------- chat (js/ui/chat.js)
   iMessage-calm: grouped bubbles with the tail on the last one, a quiet "Automated" tag on the assistant, action cards under
   a reply, quick replies above the composer. --chat-bg is the surface it sits on (the tail is cut out of it). */
.chat {
  --chat-bg: var(--bg);
  --bubble-them-bg: var(--bubble-them);
  position: relative;
  display: flex; flex-direction: column; min-width: 0;
}
.chat--on-card { --chat-bg: var(--bg-2); --bubble-them-bg: var(--bubble-them-card); }
/* Page layout: the page scrolls; the composer sticks to the bottom of the screen; with a short transcript the chat still
   fills the screen so the composer sits at the bottom (set --chat-offset to the height of anything above the chat). */
.chat--page {
  min-height: calc(100dvh - var(--navbar-h) - var(--safe-top) - var(--chat-offset, 8px) - var(--tabbar-space));
  margin-bottom: calc(-1 * var(--sp-8));   /* eats the page's bottom padding, so the composer meets the tab bar / screen edge */
}
@media (max-width: 1023.98px) {
  html.tabbar-hidden .chat--page { min-height: calc(100dvh - var(--navbar-h) - var(--safe-top) - var(--chat-offset, 8px)); margin-bottom: calc(-1 * (var(--sp-8) + var(--tabbar-space))); }
}
@media (min-width: 1024px) { .chat--page { margin-bottom: calc(-1 * var(--sp-10)); } }
.sheet .chat--page { min-height: 0; margin-bottom: -28px; }
/* Contained layout: a fixed-height box whose transcript scrolls inside (desktop cards and sheets, never a phone page). */
.chat--contained { height: var(--chat-h, 520px); border-radius: var(--r-card); background: var(--chat-bg); overflow: hidden; }
.chat-log { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; padding: 4px 0 12px; }
.chat--contained .chat-log { overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px; }
.chat-log:focus-visible { outline-offset: -3px; border-radius: var(--r-card); }
.chat-intro { margin-bottom: 12px; }
.chat-body { display: flex; flex-direction: column; min-width: 0; }
.chat-body > *, .chat-typing { scroll-margin-bottom: calc(var(--chat-dock-h, 64px) + 12px); }
.chat-empty { margin: 24px auto; color: var(--label-2); font-size: var(--fs-subhead); text-align: center; }

.chat-disclosure {
  align-self: center; display: inline-flex; align-items: center; gap: 6px;
  margin: 4px 16px 6px; padding: 5px 11px;
  border-radius: var(--r-full); background: var(--fill-4);
  color: var(--label-2); font-size: 12px; line-height: 16px; font-weight: var(--w-medium); text-align: center;
}
.chat-disclosure svg { color: var(--indigo); flex: none; }
.chat-time { align-self: center; margin: 14px 16px 2px; font-size: 12px; line-height: 16px; color: var(--label-2); font-weight: var(--w-medium); text-align: center; }
.chat-system { align-self: center; max-width: 36em; margin: 10px 16px 2px; color: var(--label-2); font-size: 12px; line-height: 16px; text-align: center; text-wrap: pretty; }

.chat-row { display: flex; align-items: flex-end; gap: 6px; min-width: 0; margin-top: 10px; padding: 0 8px; }
.chat-row + .chat-row { margin-top: 8px; }
.chat-row.is-right { justify-content: flex-end; }
.chat-stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; max-width: min(80%, 34rem); }
.chat-row.is-right .chat-stack { align-items: flex-end; }
.chat-row.is-left .chat-stack { align-items: flex-start; }
.chat-avatar { flex: none; width: 28px; height: 28px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--bg-2); margin-bottom: 1px; }
.chat-avatar svg, .chat-avatar img { width: 100%; height: 100%; display: block; }
.chat-msg { display: flex; flex-direction: column; gap: 4px; align-items: inherit; max-width: 100%; min-width: 0; }
.chat-msg.is-entering, .chat-system.is-entering { opacity: 0; transform: translateY(10px) scale(.97); }
.chat-row.is-right .chat-msg.is-entering { transform-origin: 100% 100%; }
.chat-row.is-left .chat-msg.is-entering { transform-origin: 0 100%; }
.chat-msg.is-entering.is-in, .chat-system.is-entering.is-in { opacity: 1; transform: none; transition: opacity 200ms linear, transform 360ms var(--ease); }

.chat-sender { display: flex; align-items: center; gap: 6px; max-width: 100%; padding: 0 12px 1px; font-size: 12px; line-height: 16px; color: var(--label-2); }
.chat-sender-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-auto-tag {
  flex: none; padding: 1px 6px; border-radius: var(--r-full);
  background: color-mix(in srgb, var(--indigo) 14%, transparent); color: var(--indigo-text);
  font-size: 11px; line-height: 14px; font-weight: var(--w-semibold);
}

.chat-bubble {
  position: relative; max-width: 100%; min-width: 0;
  padding: 7px 13px 8px;
  border-radius: 19px;
  font-size: var(--fs-body); line-height: 22px; letter-spacing: var(--ls-body);
  overflow-wrap: anywhere;
}
.chat-text { position: relative; z-index: 2; white-space: pre-line; -webkit-user-select: text; user-select: text; }
.chat-bubble.is-me   { background: var(--bubble-me); color: #fff; --tail: var(--bubble-me); }
.chat-bubble.is-them { background: var(--bubble-them-bg); color: var(--label); --tail: var(--bubble-them-bg); }
.chat-bubble.is-auto { background: var(--bubble-auto); color: var(--label); --tail: var(--bubble-auto); }
.chat-bubble.is-me ::selection { background: rgba(255, 255, 255, .35); }
/* The iMessage tail on a group's last bubble: a bubble-coloured curve, carved by a surface-coloured one. */
.chat-bubble.has-tail::before, .chat-bubble.has-tail::after { content: ""; position: absolute; bottom: 0; height: 20px; pointer-events: none; }
.chat-bubble.has-tail.is-right::before { z-index: 0; right: -7px; width: 20px; background: var(--tail); border-bottom-left-radius: 16px 14px; }
.chat-bubble.has-tail.is-right::after { z-index: 1; right: -10px; width: 10px; background: var(--chat-bg); border-bottom-left-radius: 10px; }
.chat-bubble.has-tail.is-left::before { z-index: 0; left: -7px; width: 20px; background: var(--tail); border-bottom-right-radius: 16px 14px; }
.chat-bubble.has-tail.is-left::after { z-index: 1; left: -10px; width: 10px; background: var(--chat-bg); border-bottom-right-radius: 10px; }
.chat-bubble.is-draft { background: transparent; color: var(--label); outline: 1.5px dashed var(--label-3); outline-offset: -1.5px; }
.chat-bubble.is-pending { opacity: .72; }
.chat-bubble.is-failed { opacity: .55; }

.chat-photo {
  position: relative; margin: 0; width: 176px; max-width: 100%; aspect-ratio: 4 / 3;
  border-radius: 18px; overflow: hidden;
  display: grid; place-items: center; align-content: center; gap: 4px;
  background: var(--fill-3); color: var(--label-2);
}
.chat-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-photo figcaption { max-width: 90%; font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-cards { display: flex; flex-direction: column; gap: 6px; width: min(100%, 22rem); }
.chat-card {
  display: block; width: 100%; min-width: 0;
  border-radius: 14px; overflow: hidden;
  background: var(--bg-2); color: var(--label); text-align: left;
  box-shadow: inset 0 0 0 var(--hairline) var(--sep);
}
.chat--on-card .chat-card { background: var(--bg-3); }
.chat-card-head { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 9px 12px; }
.chat-card-icon {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: color-mix(in srgb, var(--tone) 15%, transparent); color: var(--tone-text);
}
.chat-card-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.chat-card-title { font-size: 15px; line-height: 20px; font-weight: var(--w-semibold); letter-spacing: -0.1px; }
.chat-card-detail { font-size: 13px; line-height: 18px; color: var(--label-2); }
.chat-card-tag {
  flex: none; align-self: flex-start; margin-top: 2px; padding: 2px 7px; border-radius: var(--r-full);
  background: var(--fill-3); color: var(--label-2); font-size: 11px; line-height: 14px; font-weight: var(--w-semibold);
}
.chat-card-code { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 12px 11px 52px; }
.chat-code {
  min-width: 0; padding: 4px 9px; border-radius: 8px;
  background: var(--fill-3); color: var(--label);
  font-family: var(--font-mono); font-size: 15px; line-height: 20px; font-weight: var(--w-semibold); letter-spacing: .06em;
  overflow-wrap: anywhere; -webkit-user-select: all; user-select: all;
}
.chat-card-link, .chat-card-btn { display: block; width: 100%; color: inherit; cursor: pointer; transition: background-color var(--dur-press) linear; }
.chat-card-link .chat-card-head { padding-bottom: 2px; }
.chat-card-go { display: flex; align-items: center; gap: 2px; padding: 0 12px 10px 52px; color: var(--accent-text); font-size: 14px; line-height: 18px; font-weight: var(--w-medium); }
.chat-card-link:active, .chat-card-btn:active { background: var(--highlight); }
@media (hover: hover) and (pointer: fine) { .chat-card-link:hover, .chat-card-btn:hover { background: color-mix(in srgb, var(--bg-2) 96%, var(--label)); } }
.chat-card-link:focus-visible, .chat-card-btn:focus-visible { outline-offset: -3px; border-radius: 14px; }
.chat-quiet { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 0 12px; font-size: 12px; line-height: 16px; color: var(--label-2); }
.chat-quiet svg { flex: none; }
.chat-caption { padding: 0 12px; font-size: 12px; line-height: 16px; color: var(--label-2); }
.chat-retry {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 6px;
  color: var(--red-text); font-size: 13px; line-height: 18px; text-align: left;
}
.chat-retry::after { content: ""; position: absolute; inset: min(0px, calc(50% - var(--hit) / 2)); }
.chat-retry-go { color: var(--accent-text); font-weight: var(--w-semibold); white-space: nowrap; }
.chat-helpful { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 4px 4px 0; }
.chat-helpful-q { font-size: 13px; line-height: 18px; color: var(--label-2); margin-right: 2px; }
.chat-helpful-btns { display: inline-flex; gap: 8px; }
.chat-helpful-btn {
  position: relative; display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 12px;
  border-radius: 16px; background: var(--fill-3); color: var(--label);
  font-size: 14px; font-weight: var(--w-medium);
}
.chat-helpful-btn::after { content: ""; position: absolute; inset: min(0px, calc(50% - var(--hit) / 2)); }
.chat-helpful-btn:active { opacity: .55; }
@media (hover: hover) and (pointer: fine) { .chat-helpful-btn:hover { background: var(--fill-hover); } }
.chat-helpful-done { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; line-height: 18px; color: var(--label-2); }
.chat-helpful-done svg { color: var(--green); }

/* Typing: three dots that pulse in turn; with reduced motion they hold still and "Typing…" says it in words. */
.chat-typing { margin-top: 8px; }
.chat-typing-bubble { padding: 11px 14px 10px; }
.chat-dots { display: inline-flex; align-items: center; gap: 5px; height: 16px; }
.chat-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--label-2); opacity: .3; animation: chat-dot 1.3s ease-in-out infinite; }
.chat-dots i:nth-child(2) { animation-delay: .18s; }
.chat-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes chat-dot { 0%, 60%, 100% { opacity: .28; transform: none; } 30% { opacity: .85; transform: translateY(-2px); } }
.chat-typing-text { display: none; padding: 0 12px; font-size: 12px; line-height: 16px; color: var(--label-2); }
@media (prefers-reduced-motion: reduce) {
  .chat-dots i { animation: none !important; opacity: .5; }
  .chat-dots i:nth-child(2) { opacity: .38; }
  .chat-dots i:nth-child(3) { opacity: .26; }
  .chat-typing-text { display: block; }
}

/* The dock: quick replies + composer, on a translucent bar like Messages. */
.chat-dock {
  position: sticky; z-index: 6; bottom: var(--tabbar-space);
  display: flex; flex-direction: column; gap: 8px;
  margin-inline: calc(-1 * var(--gutter));
  padding: 8px var(--gutter);
  background: var(--material-thick);
  -webkit-backdrop-filter: var(--material-filter);
  backdrop-filter: var(--material-filter);
  box-shadow: 0 calc(-1 * var(--hairline)) 0 var(--sep);
}
.chat-dock.is-replies-only { box-shadow: none; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.chat-dock.is-replies-only:has(.chat-replies[hidden]) { display: none; }
@media (max-width: 1023.98px) {
  html.tabbar-hidden .chat--page .chat-dock { bottom: 0; padding-bottom: calc(8px + var(--safe-bottom)); }
}
.sheet .chat--page .chat-dock { bottom: -28px; margin-inline: -16px; padding: 8px 16px 12px; }
.sheet.is-modal .chat--page .chat-dock { margin-inline: -24px; padding-inline: 24px; }
.chat--contained .chat-dock { position: static; margin: 0; padding: 8px 10px 10px; background: var(--chat-bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
.chat-replies {
  display: flex; gap: 8px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  margin-inline: calc(-1 * var(--gutter)); padding: 5px var(--gutter);
  margin-block: -5px;
}
.chat-replies::-webkit-scrollbar { display: none; }
.chat--contained .chat-replies, .sheet .chat-replies { margin-inline: 0; padding-inline: 0; }
@media (min-width: 768px) { .chat-replies { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding-inline: 0; } }
.chat-reply {
  position: relative; flex: none;
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px;
  border-radius: 17px;
  background: var(--bg-2); color: var(--accent-text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 38%, transparent);
  font-size: 15px; font-weight: var(--w-medium); letter-spacing: -0.15px; white-space: nowrap;
  transition: background-color var(--dur-fast) linear, opacity var(--dur-press) linear;
}
.chat-reply::after { content: ""; position: absolute; inset: min(0px, calc(50% - var(--hit) / 2)); }
.chat-reply:active { opacity: .55; }
@media (hover: hover) and (pointer: fine) { .chat-reply:hover { background: var(--accent-tint); } }
.chat-composer { display: flex; align-items: flex-end; gap: 4px; }
.chat-attach {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin: -2px 0 -2px -8px;
  border-radius: 50%; color: var(--label-2);
  transition: background-color var(--dur-fast) linear, opacity var(--dur-press) linear;
}
.chat-attach:active { opacity: .45; }
.chat-attach:disabled { color: var(--label-3); }
@media (hover: hover) and (pointer: fine) { .chat-attach:not(:disabled):hover { background: var(--fill-4); color: var(--label); } }
.chat-field {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: flex-end; gap: 4px;
  min-height: 40px; padding: 4px 4px 4px 14px;
  border-radius: 20px;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1px var(--sep);
  transition: box-shadow 150ms linear;
}
.chat-field:focus-within { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 70%, transparent); }
.chat-input {
  flex: 1 1 auto; min-width: 0; height: 32px; max-height: 132px;
  padding: 5px 0; resize: none; overflow-y: auto;
  font-size: 17px; line-height: 22px; color: var(--label);
}
.chat-input:focus-visible { outline: none; }
.chat-input:disabled { color: var(--label-2); }
.chat-send {
  position: relative; flex: none;
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 50%; background: var(--accent-fill); color: #fff;
  transition: background-color var(--dur-fast) linear, transform var(--dur-press) var(--ease);
}
.chat-send::after { content: ""; position: absolute; inset: -6px; }
.chat-send:active:not(:disabled) { transform: scale(.9); }
.chat-send:disabled { background: var(--fill); color: var(--bg-2); cursor: default; }
@media (hover: hover) and (pointer: fine) { .chat-send:not(:disabled):hover { filter: brightness(.92); } }
.chat-composer-note { font-size: 13px; line-height: 18px; color: var(--label-2); text-align: center; text-wrap: pretty; }
@media (min-width: 768px) { .chat-input { font-size: 16px; line-height: 21px; } }

/* ---------------------------------------------------------------- upload (js/ui/upload.js) */
.upload { min-width: 0; }
.upload-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-zone {
  position: relative; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 180px; padding: 24px 20px;
  border-radius: var(--r-card);
  background: var(--bg-2);
  outline: 1.5px dashed var(--label-3); outline-offset: -1.5px;
  text-align: center;
  transition: background-color var(--dur-fast) linear, transform var(--dur-press) var(--ease);
}
.upload-zone:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.upload-zone:active:not(:disabled) { transform: scale(.99); }
.upload-zone.is-dragging { background: var(--accent-tint); outline: 2px dashed var(--accent); outline-offset: -2px; }
.upload-zone:disabled { opacity: .5; cursor: default; }
@media (hover: hover) and (pointer: fine) { .upload-zone:not(:disabled):hover { background: color-mix(in srgb, var(--bg-2) 96%, var(--label)); } }
.upload-zone-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 6px; border-radius: 14px; background: var(--accent-tint); color: var(--accent-text); }
.upload-zone-title { font-size: var(--fs-headline); line-height: var(--lh-headline); font-weight: var(--w-semibold); text-wrap: balance; }
.upload-zone-hint { max-width: 34em; font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-2); text-wrap: pretty; }
.upload-zone-btn {
  display: inline-flex; align-items: center; min-height: 34px; margin-top: 10px; padding: 0 16px;
  border-radius: var(--r-full); background: var(--accent-tint); color: var(--accent-text);
  font-size: 15px; font-weight: var(--w-semibold);
}
.upload-panel { display: flex; flex-direction: column; gap: 12px; padding: 12px; border-radius: var(--r-card); background: var(--bg-2); }
.upload-media {
  position: relative; align-self: center;
  width: min(100%, 360px); max-height: 420px; aspect-ratio: var(--ratio, 9 / 16);
  border-radius: 14px; overflow: hidden; background: #000;
}
.upload--video .upload-media { width: auto; height: min(420px, 60vh); max-width: 100%; }
.upload--video .upload-media.is-wide { width: min(100%, 560px); height: auto; }
.upload-media video, .upload-media img { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.upload-media.is-placeholder { display: grid; place-items: center; background: var(--fill-3); color: var(--label-2); height: 200px; }
.upload-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.upload-row-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--fill-3); color: var(--label-2); }
.upload-row-icon.is-done { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.upload-row-text { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.upload-name { font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: var(--w-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-meta { font-size: 13px; line-height: 18px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.upload-bar { display: block; height: 6px; margin: 4px 0 2px; border-radius: 3px; overflow: hidden; background: var(--fill-3); }
.upload-bar > span { display: block; height: 100%; width: var(--p, 0%); border-radius: 3px; background: var(--accent); transition: width 300ms var(--ease); }
.upload-actions { flex: none; display: flex; gap: 2px; }
.upload-action {
  position: relative; display: inline-flex; align-items: center; height: 32px; padding: 0 10px;
  border-radius: var(--r-md); color: var(--accent-text); font-size: 15px; font-weight: var(--w-medium);
}
.upload-action::after { content: ""; position: absolute; inset: min(0px, calc(50% - var(--hit) / 2)); }
.upload-action.is-destructive { color: var(--red-text); }
.upload-action:active { opacity: .45; }
@media (hover: hover) and (pointer: fine) { .upload-action:hover { background: var(--fill-4); } }
.upload-error { margin-top: 8px; padding: 0 4px; font-size: 13px; line-height: 18px; color: var(--red-text); text-wrap: pretty; }
.upload-error:empty { display: none; }
@media (max-width: 420px) {
  .upload-row { flex-wrap: wrap; }
  .upload-actions { width: 100%; justify-content: flex-end; margin-top: -4px; }
}

/* ---------------------------------------------------------------- forms from a schema (js/ui/form.js) */
.sform { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.sform .list-section + .list-section { margin-top: 0; }
.sform-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.sform-label-row .field-label { padding-right: 0; }
.sform-field-action { margin: -6px -6px -6px 0; }
.sform-block { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sform-block > .segmented { margin-top: 2px; }
.sform-select-wrap { position: relative; display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; color: var(--label-2); }
.sform-select-wrap svg { flex: none; pointer-events: none; }
.sform-select {
  -webkit-appearance: none; appearance: none;
  max-width: 100%; min-width: 0; min-height: 44px; margin: -11px 0; padding: 0 2px 0 8px;
  border: 0; background: none; color: var(--label-2);
  font-size: var(--fs-body); text-align: right; text-align-last: right; cursor: pointer;
  text-overflow: ellipsis;
}
.sform-select:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 6px; }
.sform-row .list-row-main { gap: 12px; }
.sform-row .list-row-title { flex: 1 1 auto; }
.sform-row .list-row-accessory { min-width: 0; max-width: 62%; }
.sform-thumb { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; overflow: hidden; background: var(--fill-3); color: var(--label-2); flex: none; }
.sform-thumb svg { width: 100%; height: 100%; display: block; }
.sform-thumb.is-empty svg { width: 16px; height: 16px; }
.sform-swatches { display: flex; flex-wrap: wrap; gap: 6px 4px; }
.sform-swatch {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 76px; padding: 4px 0;
  border-radius: 12px; color: var(--label-2);
  -webkit-tap-highlight-color: transparent;
}
.sform-swatch-dot {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  color: transparent;
  transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease);
}
.sform-swatch-dot svg { filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, .55)); }
.sform-swatch.is-selected .sform-swatch-dot { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), 0 0 0 2.5px var(--bg), 0 0 0 4.5px var(--accent); color: #fff; }
.sform-swatch.is-selected .sform-swatch-label { color: var(--label); font-weight: var(--w-semibold); }
.sform-swatch:active .sform-swatch-dot { transform: scale(.94); }
.sform-swatch:focus-visible { outline-offset: 0; }
.sform-swatch-label { font-size: 12px; line-height: 15px; text-align: center; text-wrap: balance; }
@media (hover: hover) and (pointer: fine) { .sform-swatch:hover { background: var(--fill-4); } }
.sform-locked { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--fill-4); }
.sform-locked-label { display: flex; align-items: center; gap: 5px; font-size: 13px; line-height: 18px; font-weight: var(--w-medium); color: var(--label-2); }
.sform-locked-value { font-size: var(--fs-body); line-height: var(--lh-body); color: var(--label); }
.sform-locked-why { font-size: 13px; line-height: 18px; color: var(--label-2); text-wrap: pretty; }
.sform-links .sform-link-list { margin: 2px 0 0; }
.sform-link { display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 2px 12px 2px 2px; }
.sform-link + .sform-link { box-shadow: inset 0 var(--hairline) 0 var(--sep); }
.sform-link-remove { color: var(--red); }
.sform-link-remove .icon-btn-face { color: var(--red); }
.sform-link-input { flex: 1 1 auto; min-width: 0; height: 44px; font-size: var(--fs-body); color: var(--label); }
.sform-link-input:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.sform-link .sform-select-wrap { flex: none; max-width: 48%; }
.sform-links > .btn { align-self: flex-start; margin-left: -10px; }
.sform-error { padding: 10px 14px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red-text); font-size: var(--fs-subhead); line-height: var(--lh-subhead); }
.sform-empty { color: var(--label-2); font-size: var(--fs-subhead); }

/* ---------------------------------------------------------------- away pill (shell) */
.away-pill {
  position: relative;
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  height: 24px; padding: 0 9px 0 7px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--indigo) 14%, transparent);
  color: var(--indigo-text);
  font-size: 12px; line-height: 1; font-weight: var(--w-semibold); letter-spacing: 0;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: gap var(--dur-fast) var(--ease), padding var(--dur-fast) var(--ease), opacity var(--dur-press) linear;
}
.away-pill::after { content: ""; position: absolute; z-index: 1; inset: min(0px, calc(50% - var(--hit) / 2)); }
.away-pill svg { flex: none; }
.away-pill-text { display: inline-block; overflow: hidden; max-width: 8em; transition: max-width var(--dur-fast) var(--ease), opacity var(--dur-fast) linear; }
.away-pill:active { opacity: .55; }
@media (hover: hover) and (pointer: fine) { .away-pill:hover { background: color-mix(in srgb, var(--indigo) 20%, transparent); } }

/* ---------------------------------------------------------------- placeholder (stub views) */
.placeholder { text-align: center; }
.placeholder-links { margin-top: var(--sp-6); text-align: left; }

/* ---------------------------------------------------------------- dev gallery (#/_gallery) */
.gallery-demo { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.gallery-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; }
.gallery-icon { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 10px; font-size: 10px; line-height: 12px; color: var(--label-2); text-align: center; overflow-wrap: anywhere; }
.gallery-icon svg { color: var(--label); }
.gallery-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery-swatch { border-radius: 12px; padding: 10px; font-size: 11px; line-height: 14px; background: var(--bg-2); }
.gallery-swatch span { display: block; height: 34px; border-radius: 8px; margin-bottom: 6px; background: var(--sw); }
.gallery-art { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.gallery-art > div { border-radius: 14px; overflow: hidden; aspect-ratio: 1; background: var(--bg-3); }
.gallery-art svg { width: 100%; height: 100%; display: block; }

/* Filled pills on light hues keep the bright colour and use dark text. */
.pill-filled.tone-green, .pill-filled.tone-yellow, .pill-filled.tone-orange, .pill-filled.tone-teal { color: #000; background: var(--tone); }

/* ---------------------------------------------------------------- forced colours (Windows High Contrast)
   Backgrounds and shadows are dropped in this mode, so anything drawn only with them gets a system-colour
   border or fill. Text and focus outlines are recoloured by the browser. */
@media (forced-colors: active) {
  .btn:not(.btn-plain), .icon-btn-gray .icon-btn-face, .icon-btn-tinted .icon-btn-face, .icon-btn-filled .icon-btn-face,
  .chip, .toast-action, .stepper-control, .sheet-close, .search-field, .field-control { border: 1px solid ButtonText; }
  .chip.is-selected { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  .chip.is-selected svg { color: HighlightText; }

  .switch-track { border: 1px solid CanvasText; }
  .switch-thumb { forced-color-adjust: none; background: CanvasText; box-shadow: none; top: 1px; left: 1px; }
  .switch-input:checked + .switch-track { forced-color-adjust: none; background: Highlight; border-color: Highlight; }
  .switch-input:checked + .switch-track .switch-thumb { background: HighlightText; }
  .switch-input:disabled + .switch-track { border-color: GrayText; }
  .switch-input:focus-visible + .switch-track { outline-color: Highlight; }

  .segmented { border: 1px solid ButtonText; }
  .segmented-thumb { forced-color-adjust: none; background: Highlight; box-shadow: none; }
  .segmented-item.is-selected { forced-color-adjust: none; color: HighlightText; }
  .segmented-item.is-selected .segmented-badge { color: HighlightText; }

  .slider-input { forced-color-adjust: none; }
  .slider-input::-webkit-slider-runnable-track { background: linear-gradient(to right, Highlight 0 var(--p), GrayText var(--p) 100%); }
  .slider-input::-moz-range-track { background: linear-gradient(to right, Highlight 0 var(--p), GrayText var(--p) 100%); }
  .slider-input::-webkit-slider-thumb { background: CanvasText; box-shadow: none; }
  .slider-input::-moz-range-thumb { background: CanvasText; box-shadow: none; }
  .meter-track { border: 1px solid CanvasText; }
  .meter-fill { forced-color-adjust: none; background: Highlight; }
  .step-dot { box-shadow: none; border: 1.5px solid CanvasText; }

  .card, .list, .stat, .sheet, .alert, .action-sheet-group, .popover, .toast, .chart-tip { border: 1px solid CanvasText; }
  .pill-tinted, .pill-filled { border: 1px solid currentColor; }
  .sheet-grabber { forced-color-adjust: none; background: CanvasText; }
  .skeleton { border: 1px solid GrayText; }
  .list-row-inner.is-interactive:hover, .list-row-inner.is-interactive:active { outline: 2px solid Highlight; outline-offset: -2px; }
  .chart-col path, .chart-col rect { forced-color-adjust: none; fill: CanvasText; }
  .chart-col.is-partial path { fill: GrayText; }
  .flow-step-bar { border: 1px solid CanvasText; background: Canvas; }
  .flow-step-bar::before { forced-color-adjust: none; background: Highlight; }
  .check-circle { box-shadow: none; border: 1.5px solid CanvasText; }
  .check-row.is-done .check-circle { forced-color-adjust: none; background: Highlight; border-color: Highlight; }
  .check-row.is-done .check-tick { color: HighlightText; }
  .choice { border: 1px solid CanvasText; }
  .choice.is-selected { outline: 3px solid Highlight; outline-offset: -1px; }
  .choice-mark { box-shadow: none; border: 1.5px solid CanvasText; }
  .choice.is-selected .choice-mark { forced-color-adjust: none; background: Highlight; border-color: Highlight; }
  .choice.is-selected .choice-mark svg { color: HighlightText; }
  .choice-badge, .copy-btn.is-capsule { border: 1px solid currentColor; }
  .device-frame { border: 1px solid CanvasText; }
  .score-part-bar { border: 1px solid CanvasText; background: Canvas; }
  .score-part-bar > span { forced-color-adjust: none; background: Highlight; }
  .copy-block, .chat-card, .chat-field, .chat-reply, .chat-helpful-btn, .upload-panel, .sform-locked, .away-pill { border: 1px solid CanvasText; }
  .chat-bubble { border: 1px solid CanvasText; }
  .chat-bubble.has-tail::before, .chat-bubble.has-tail::after { display: none; }
  .chat-send { border: 1px solid ButtonText; }
  .chat-dots i { forced-color-adjust: none; background: CanvasText; }
  .upload-zone { outline-color: CanvasText; }
  .upload-bar { border: 1px solid CanvasText; }
  .upload-bar > span { forced-color-adjust: none; background: Highlight; }
  .sform-swatch-dot { forced-color-adjust: none; border: 1px solid CanvasText; }
  .sform-swatch.is-selected .sform-swatch-dot { outline: 3px solid Highlight; outline-offset: 2px; }
}
