/* Page shell, header, grid, tab bar */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--s4) + env(safe-area-inset-top)) calc(var(--gutter) + env(safe-area-inset-right)) calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
}
.page.gate { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.page:has(.bar) { padding-bottom: calc(var(--tab-h) + var(--bar-h) + 28px + env(safe-area-inset-bottom)); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin: 0 0 var(--s3); }
.page-head h1 { margin: 0; }
.page-head.brandbar h1 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.04em; }
.wordmark-heading { display: flex; align-items: center; gap: 0; }
.wordmark { display: block; width: auto; height: 1.375rem; }
.label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: var(--s5) 0 var(--s2) 4px; }
.label:first-of-type { margin-top: var(--s3); }

/* Group switcher: a quiet teal control */
.switch { position: relative; display: inline-flex; align-items: center; max-width: 60%; }
.switch select {
  appearance: none; -webkit-appearance: none;
  width: auto; max-width: 100%; min-height: 44px; padding: 0 14px 0 0;
  border: 0; background: none; box-shadow: none; border-radius: 0;
  color: var(--teal); font: 600 var(--fs-sm)/1.2 var(--font);
  text-align: right; text-overflow: ellipsis; cursor: pointer;
}
.switch::after { content: "\25BE"; position: absolute; right: 0; color: var(--teal); font-size: var(--fs-sm); pointer-events: none; }
.switch select:focus { box-shadow: none; }
.switch:has(select:focus-visible) { border-radius: 8px; box-shadow: var(--ring); }

/* Chip toggle: a real checkbox laid over the chip */
.chips { display: flex; gap: var(--s2); margin: 0 0 var(--s3); }
.chip {
  position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border-radius: 20px; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
  background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px #ddd;
}
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip:has(input:checked) { background: var(--ink); color: var(--ink-inverse); box-shadow: none; }
.chip:has(input:focus-visible) { box-shadow: var(--ring); }

/* Two-column marketplace grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px var(--s3); }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--card); box-shadow: 0 -1px 0 var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tabbar button {
  flex: 1; min-width: 0; min-height: var(--tab-h); border: 0; border-radius: 0; background: none;
  flex-direction: column; gap: 3px; padding: 6px 2px 4px;
  font-size: 0.6875rem; font-weight: 500; color: var(--muted); position: relative;
}
.tabbar svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button[aria-current="page"] { color: var(--ink); font-weight: 700; }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--teal); color: #fff; font-size: 0.6875rem; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.tabbar button:focus-visible { box-shadow: inset 0 0 0 2px var(--ink); }
