/*
 * The demo: a working replica of CoSavr's Home, Plan and Add sheet.
 *
 * Every number here is taken from the app, not chosen by eye. The app's points
 * map to CSS pixels one for one, so CSSpacing.lg = 16 really is 16px.
 *
 *   CSSpacing        screen 20 · xs 4 · sm 8 · md 12 · lg 16 · xl 24 · xxl 32
 *   CSRadius         chip 12 · card 14 · panel 20
 *   HeroSpendCard    padding 24, radius 20, amount 48 bold rounded,
 *                    shadow Mango 35% / 16 / y8, gradient Mango to Papaya
 *   csCard           padding 16 on the card surface, radius 14
 *   AmountKeypad     keys 64 tall, radius 20, 26 medium rounded
 *   Tab bar          the system's on iOS 26: one glass capsule, Search apart
 *
 * ⚠️ Three colours differ from the app on purpose, because the web is held to
 * WCAG AA and these measure under it (antislop R-25):
 *   - text on the hero and on the PRO tag is --on-accent, not white (white on
 *     Papaya is 2.06:1);
 *   - the Money out amount is --accent-text, not Mango (3.00:1 on the sheet);
 *   - small Money in figures are --info-text, not Sky (3.32:1 on a card).
 */

:root {
  /* The app sets every amount in SF Rounded (`design: .rounded`) and the rest
   * in SF Pro. ui-rounded and -apple-system resolve to exactly those on the
   * Apple devices that run the app; elsewhere they fall back to the system
   * sans, which is the closest thing available. */
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, system-ui,
    "Segoe UI", Roboto, sans-serif;
  --font-app: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;

  --app-screen: 20px;
  --app-xs: 4px;
  --app-sm: 8px;
  --app-md: 12px;
  --app-lg: 16px;
  --app-xl: 24px;
  --r-chip: 12px;
  --r-card: 14px;
  --r-panel: 20px;

  /* csGlassBorder: a soft catch-light in light mode, faint in dark. */
  --glass-border: rgb(255 255 255 / 0.65);
}

@media (prefers-color-scheme: dark) {
  :root { --glass-border: rgb(255 255 255 / 0.14); }
}

/* Inline SVG with no intrinsic size fills its container, so every glyph gets an
 * explicit box. */
#demo svg { flex: none; width: 16px; height: 16px; }

/* Controls drawn smaller than a fingertip keep their look and get a 44px hit
 * area from this, as SwiftUI gives a button its content shape. */
.hit { position: relative; }
.hit::after { content: ""; position: absolute; inset: -12px -4px; }

/* --- Device frame ------------------------------------------------------
 * Glass instance 2 of 2 (DESIGN.md caps it there). It is the chrome holding
 * the screen, which is exactly the "navigation layer" use the app's own
 * CSGlass comment reserves glass for.
 */

.device {
  position: relative;
  min-width: 0;
  width: 100%;
  max-width: 390px;              /* iPhone logical width */
  margin-inline: auto;
  padding: 10px;
  border-radius: 44px;
  background: color-mix(in srgb, var(--bg-secondary) 70%, transparent);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.35);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .device {
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    backdrop-filter: blur(20px) saturate(1.4);
  }
}

.device__screen {
  position: relative;
  overflow: hidden;
  /* The phone sizes its own contents, not the page's. The app shrinks figures
   * with `csFittedAmount()`; `cqi` is the honest web equivalent, and it is
   * what stops a 48px number setting a min-content floor that pushes the
   * whole grid track past a 320px viewport. */
  container-type: inline-size;
  min-width: 0;
  border-radius: 36px;
  background: var(--bg-primary);
  height: clamp(30rem, 68vh, 44rem);
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

/* CSCanvas: the flat ground plus two radial blobs. */
.device__screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(340px 340px at 82% -4%,
      color-mix(in srgb, var(--accent-primary) 18%, transparent), transparent 70%),
    radial-gradient(300px 300px at 12% 96%,
      color-mix(in srgb, var(--info) 14%, transparent), transparent 70%);
  pointer-events: none;
}

/* --- App scroll area ---------------------------------------------------- */

.app {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  /* No `overscroll-behavior: contain`: the phone sits in the page's reading
   * path, so once its list ends the scroll has to carry on to the page, or a
   * swipe across the phone traps the reader there. */
  padding: var(--app-sm) var(--app-screen) 104px;
  -webkit-overflow-scrolling: touch;
}

/* Zero specificity, so every class below sets its own spacing. */
:where(#demo) p { margin: 0; }

.app__stack { display: flex; flex-direction: column; gap: var(--app-lg); }

/* csTabRoot: the title and the avatar on one line (`.inlineLarge`). */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--app-sm);
  padding-block: var(--app-xs) var(--app-md);
}

.nav__title {
  font-size: 34px;
  font-size: clamp(26px, 9cqi, 34px);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

/* The avatar: a monogram on the hero gradient in a round glass rim. With no
 * one signed in to the demo, it shows the app's generic person. */
.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 2px;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg-secondary) 60%, transparent);
  cursor: pointer;
}

.avatar span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: var(--on-accent);
}

.avatar svg { width: 18px; height: 18px; }

/* --- Hero --------------------------------------------------------------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--app-sm);
  padding: var(--app-xl);
  border-radius: var(--r-panel);
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  box-shadow: 0 8px 16px color-mix(in srgb, var(--accent-primary) 35%, transparent);
  cursor: pointer;
}

.hero__label { font-size: 15px; font-weight: 600; }
.hero__renew { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }

.hero__amount {
  font-family: var(--font-rounded);
  font-size: 48px;                 /* fallback where cqi is unsupported */
  font-size: clamp(1.9rem, 13cqi, 48px);
  font-weight: 700;
  line-height: 1.1;
  padding-top: var(--app-xs);
  font-variant-numeric: tabular-nums;
  /* "left" beside the figure, as in the app's HStack, and under it when the
   * two don't fit. */
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--app-xs);
}

/* "left" beside the figure: csBody semibold. */
.hero__unit { font-family: var(--font-app); font-size: 17px; font-weight: 600; }

/* Plan, and each other part of left that isn't zero. */
.hero__lines {
  display: flex;
  flex-direction: column;
  gap: var(--app-xs);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.hero__lines strong { font-weight: 600; }

.hero__bills,
.hero__see {
  font: inherit;
  font-size: 15px;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.hero__see { font-weight: 600; }

/* The bills still to pay, under Plan (iOS-517). Its hit area stops short of
 * the lines either side, which open the sheet at its top. */
.hero__bills {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.hero__bills.hit::after { inset: -4px; }

.hero__pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: var(--app-xs) var(--app-sm);
  margin-top: var(--app-xs);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.22);
  border: 1px solid rgb(255 255 255 / 0.3);
}

.hero__progress {
  align-self: stretch;
  height: 6px;
  margin-top: var(--app-xs);
  border-radius: 999px;
  background: color-mix(in srgb, var(--on-accent) 20%, transparent);
  overflow: hidden;
}

.hero__progress span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--on-accent);
}

.hero__status {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--app-xs) var(--app-md);
  font-size: 15px;
}

/* --- Cards -------------------------------------------------------------- */

.card {
  padding: var(--app-lg);
  border-radius: var(--r-card);
  background: color-mix(in srgb, var(--bg-secondary) 82%, transparent);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--text-primary) 6%, transparent);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--app-sm);
}

/* csOverline: the app's caption-2 bold, uppercase, slightly tracked. */
.overline {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.card__amount {
  font-family: var(--font-rounded);
  font-size: 34px;
  font-size: clamp(1.6rem, 9cqi, 34px);
  font-weight: 700;
  line-height: 1.15;
  margin-top: var(--app-sm);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.card__amount--negative { color: var(--danger); }

/* TotalCashCard: the title and figure side by side, stacked when they don't
 * fit, then Overdrawn. */
.cash {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--app-sm);
}

.cash__head {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--app-xs) var(--app-sm);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.cash__amount { font-family: var(--font-rounded); font-variant-numeric: tabular-nums; }
.cash__amount--negative { color: var(--danger); }

/* Not red on red: dark text on a red tint. */
.cash__pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: var(--app-xs) var(--app-sm);
  border-radius: 999px;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--danger) 15%, transparent);
}

/* CSProBadge. */
.pro {
  margin-left: 2px;
  padding: 2px var(--app-sm);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--on-accent);
  background: var(--accent-primary);
}

.card__sub { font-size: 15px; color: var(--text-secondary); margin-top: var(--app-sm); }

/* The window menu's label in SpendingCard. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--app-xs);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-primary-tint);
  border: 0;
  border-radius: 999px;
  padding: var(--app-xs) var(--app-md);
  cursor: pointer;
}

.chip svg { width: 11px; height: 11px; }

/* "10 payments · 24 Oct – 6 Nov", which opens the rows. */
.card__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--app-xs);
  margin-top: var(--app-sm);
  font: inherit;
  font-size: 15px;
  color: var(--text-secondary);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.card__toggle svg { width: 11px; height: 11px; transition: transform 200ms ease; }
.card__toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.card__more {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-text);
  background: none;
  border: 0;
  padding: 0;
  margin-top: var(--app-sm);
  cursor: pointer;
}

/* PlanStat: Income, Bills and Left under Plan's figure. */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--app-sm) var(--app-lg);
  margin: var(--app-md) 0 0;
}

.stats dt,
.stats__share { font-size: 15px; color: var(--text-secondary); }
.stats dd { margin: 0; }

.stats__value {
  font-family: var(--font-rounded);
  font-size: 17px;
  font-weight: 600;
  margin-top: 2px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stats__value--out { color: var(--accent-text); }
.stats__value--in { color: var(--info-text); }

/* --- Money out by category ---------------------------------------------- */

/* The donut sits beside its legend when both fit, and above it when they
 * don't, which is what the app's ViewThatFits chooses on a phone. */
.donut {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--app-md) var(--app-lg);
  padding-block: var(--app-md) var(--app-sm);
}

#demo .donut__chart { width: 120px; height: 120px; }

.legend {
  flex: 1 1 15rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--app-sm);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
}

.legend li { display: flex; align-items: center; gap: var(--app-sm); }
.legend__dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }

.legend__name {
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend__amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend__share { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* --- Transaction rows --------------------------------------------------- */

.tx { display: flex; flex-direction: column; }

.tx__day {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  padding-top: var(--app-sm);
}

.tx__row {
  display: flex;
  align-items: center;
  gap: var(--app-md);
  padding-block: var(--app-xs);
}

.tx__icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--tint);
  background: color-mix(in srgb, var(--tint) 15%, transparent);
}

.tx__body { flex: 1; min-width: 0; }

.tx__title {
  font-size: 17px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx__date { font-size: 15px; color: var(--text-secondary); margin-top: 2px; }

.tx__amount {
  font-family: var(--font-rounded);
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  white-space: nowrap;
}

.tx__amount--in { color: var(--info-text); }

/* Newly added rows arrive rather than appear, which is the app's
 * CSTransition.rise. The value inside never animates (iOS-150). */
@media (prefers-reduced-motion: no-preference) {
  .tx__row--new { animation: rise 320ms ease both; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* --- Money out and Money in, a swipe apart ------------------------------ */

.pager {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  /* Full width, so a page turns across the whole screen. */
  margin-inline: calc(-1 * var(--app-screen));
  transition: height 200ms ease;
}

.pager::-webkit-scrollbar { display: none; }

.pager__page {
  flex: 0 0 100%;
  min-width: 0;
  padding-inline: var(--app-screen);
  scroll-snap-align: start;
}

/* CSPageIndicator: the current page a 22px capsule, the other a dot. Each is
 * a button, so the cards can be switched without a swipe. */
.dots { display: flex; justify-content: center; margin-top: calc(-1 * var(--app-sm)); }

.dots button {
  position: relative;
  width: 30px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

/* 44px wide to a finger while the dots stay as close as the app's. */
.dots button::after { content: ""; position: absolute; inset: 0 -7px; }

.dots button::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  margin: auto;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-primary) 25%, transparent);
  transition: width 200ms ease;
}

.dots button[aria-current="true"]::before { width: 22px; background: var(--accent-primary); }

/* --- Grouped lists: Plan and This period -------------------------------- */

.group__head {
  display: flex;
  align-items: center;
  gap: var(--app-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: var(--app-lg) var(--app-lg) 6px;
}

.group__total { margin-left: auto; font-variant-numeric: tabular-nums; }

.group__body {
  padding: var(--app-xs) var(--app-lg);
  border-radius: var(--r-panel);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
}

.group__foot { font-size: 13px; color: var(--text-secondary); padding: 6px var(--app-lg) 0; }

.group__body > .tx__row { padding-block: 6px; }
.group__body > .tx__row + .tx__row { border-top: 1px solid var(--border); }

.line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--app-md);
  padding-block: 11px;
  font-size: 17px;
  color: var(--text-primary);
}

.line + .line { border-top: 1px solid var(--border); }
.line__body { min-width: 0; }
.line__sub { font-size: 15px; color: var(--text-secondary); margin-top: 2px; }

.line__amount {
  font-family: var(--font-rounded);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.line__amount--in { color: var(--info-text); }
.line--total { font-weight: 600; }
.line__empty { font-size: 15px; color: var(--text-secondary); padding-block: 11px; }

/* Smart plan's row: the name and PRO, and the system switch, off. */
.smart { display: inline-flex; align-items: center; gap: 6px; }

.switch {
  flex: none;
  position: relative;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-primary) 16%, transparent);
}

.switch::after {
  content: "";
  position: absolute;
  inset: 2px auto 2px 2px;
  width: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.2);
}

/* --- Tab bar ------------------------------------------------------------ */

.tabbar {
  position: absolute;
  left: var(--app-lg);
  right: var(--app-lg);
  bottom: var(--app-md);
  z-index: 3;
  display: flex;
  gap: var(--app-sm);
}

.tabbar__tabs,
.tabbar__search {
  height: 62px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-secondary) 88%, transparent);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 10px rgb(0 0 0 / 0.08);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .tabbar__tabs,
  .tabbar__search {
    background: color-mix(in srgb, var(--bg-secondary) 55%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.6);
    backdrop-filter: blur(18px) saturate(1.6);
  }
}

.tabbar__tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  padding: var(--app-xs);
}

.tabbar__btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: none;
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  color: var(--text-primary);
}

#demo .tabbar__btn svg { width: 22px; height: 22px; }
.tabbar__btn span { font-size: 10px; font-weight: 600; }

/* The selected tab: the tint, on a lens of its own. */
.tabbar__btn[aria-current="page"] {
  color: var(--accent-text);
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.tabbar__search {
  flex: none;
  width: 62px;
  display: grid;
  place-items: center;
  padding: 0;
  font: inherit;
  cursor: pointer;
  color: var(--text-primary);
}

.tabbar__search[aria-current="page"] { color: var(--accent-text); }
#demo .tabbar__search svg { width: 22px; height: 22px; }

/* Below roughly a folded-phone width the labels no longer fit the capsule.
 * The glyphs stay; every button keeps an accessible name. */
@container (max-width: 310px) {
  .tabbar__btn span { display: none; }
}

/* --- Panels: the screens the demo doesn't build ------------------------- */

.panel {
  padding: var(--app-xl);
  border-radius: var(--r-card);
  background: color-mix(in srgb, var(--bg-secondary) 82%, transparent);
  border: 1px solid var(--glass-border);
  font-size: 15px;
  color: var(--text-secondary);
}

.panel p + p { margin-top: var(--app-md); }

/* --- Sheets ------------------------------------------------------------- */

.sheet {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: 36px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.sheet[hidden] { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: sheet-up 260ms ease both; }
}

@keyframes sheet-up {
  from { transform: translateY(12%); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* Cancel and Save either side of a centred title. */
.sheet__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--app-sm);
  padding: var(--app-md) var(--app-lg);
}

.sheet__bar > :last-child { justify-self: end; }
.sheet__title { font-size: 17px; font-weight: 600; }

.sheet__action {
  justify-self: start;
  min-height: 44px;
  background: none;
  border: 0;
  font: inherit;
  font-size: 17px;
  color: var(--accent-text);
  cursor: pointer;
  padding: 0 var(--app-xs);
  border-radius: var(--app-xs);
}

.sheet__action--strong { font-weight: 600; }
.sheet__action:disabled { color: var(--text-secondary); opacity: 0.55; cursor: not-allowed; }

.sheet__body {
  position: relative;               /* offsetTop for "Still to pay" */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--app-screen) var(--app-xl);
}

.sheet__body > .group:first-child .group__body { margin-top: var(--app-sm); }

/* --- The Add sheet ------------------------------------------------------ */

.sheet__amount {
  font-family: var(--font-rounded);
  font-size: 48px;
  font-size: clamp(1.8rem, 13cqi, 48px);
  font-weight: 700;
  text-align: center;
  padding-block: var(--app-md) var(--app-xl);
  font-variant-numeric: tabular-nums;
  color: var(--accent-text);
}

.sheet__amount[data-type="income"] { color: var(--info-text); }
.sheet__amount[data-empty="true"] { color: var(--text-secondary); }

/* The system's segmented control: a track with a raised thumb on the choice. */
.seg {
  display: flex;
  padding: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-primary) 9%, transparent);
  margin-bottom: var(--app-xl);
}

.seg__btn {
  position: relative;
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
}

/* Money out's filter sits between the card's head and its figure. */
.seg--card { margin: var(--app-sm) 0 0; }

/* The track is the system's 36px; the hit area reaches 44. */
.seg__btn::after { content: ""; position: absolute; inset: -4px 0; }

.seg__btn[aria-pressed="true"] {
  font-weight: 600;
  background: var(--bg-secondary);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.12);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--app-sm);
  margin-bottom: var(--app-xl);
}

.keypad button {
  min-height: 64px;
  font-family: var(--font-rounded);
  font-size: 26px;
  font-weight: 500;
  border-radius: var(--r-panel);
  border: 1px solid var(--glass-border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 120ms ease, transform 120ms ease;
}

.keypad button:hover { background: var(--accent-primary-tint); }
.keypad button:active { background: var(--accent-primary-tint); transform: scale(0.96); }
#demo .keypad svg { width: 24px; height: 24px; }

.sheet__label { margin-bottom: var(--app-sm); }

.picker {
  padding-inline: var(--app-lg);
  border-radius: var(--r-card);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
}

.picker__head,
.picker__row {
  display: flex;
  align-items: center;
  gap: var(--app-md);
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--text-primary);
  background: none;
  border: 0;
  padding: var(--app-lg) 0;
  cursor: pointer;
  text-align: left;
}

.picker__row { padding-block: var(--app-md); border-top: 1px solid var(--border); }
.picker__name { flex: 1; min-width: 0; }
.picker__name--none { color: var(--text-secondary); }
.picker__head svg { width: 13px; height: 13px; color: var(--text-secondary); transition: transform 200ms ease; }
.picker__head[aria-expanded="true"] > svg { transform: rotate(180deg); }
.picker__check { display: grid; color: var(--text-primary); }
#demo .picker__check svg { width: 18px; height: 18px; }

/* CategoryBadge: the glyph on a 16% tint, in a square rounded to 30%. */
.badge {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  border-radius: calc(var(--size) * 0.3);
  color: var(--tint);
  background: color-mix(in srgb, var(--tint) 16%, transparent);
}

#demo .badge svg { width: calc(var(--size) * 0.5); height: calc(var(--size) * 0.5); }

/* --- Demo framing on the page ------------------------------------------ */

.demo__reset {
  font: inherit;
  font-size: 0.875rem;
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
