/* The Census library (live-rarity-v1, 6 Nov 2026). G: "filter by the traits and show them rather than list out ... it could
   list and filter and basically operate like the Locker and Bean Builder library." Same shelf as Build-A-Bean, census colours.
   Beanville tokens (beanville.css): --bg --surface --surface-2 --edge --text --muted --line --butter-soft. */
body.cs-page { --cs-sign: #2F7D6B; --cs-sign-2: #1F5E50; --cs-ink: #FFF6E6; --cs-butter: #FFC93C; --cs-ok: #2F7D4F; --cs-gold: #C99A1A; }
body.cs-page[data-theme="dark"] { --cs-sign: #1D5A4D; --cs-sign-2: #134238; --cs-ok: #6FCF97; --cs-gold: #F2C14E; }
body.cs-page[data-theme="dood"] { --cs-sign: #3a1166; --cs-sign-2: #24093f; --cs-butter: #ff3ea5; --cs-ok: #7CFFB2; --cs-gold: #FFE066; }

body.cs-page main.bm-wrap > * { min-width: 0; max-width: 100%; }
html:has(body.cs-page), body.cs-page { overflow-x: clip !important; overflow-y: visible !important; }

/* the two views */
.cs-views { display: flex; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.cs-view { border: 3px solid var(--edge); border-radius: 999px; background: var(--surface); color: var(--text); font: 800 15px var(--f-body); padding: 8px 16px; cursor: pointer; min-height: 44px; box-shadow: 0 3px 0 var(--edge); }
.cs-view[aria-selected="true"] { background: var(--cs-sign); color: var(--cs-ink); }
.cs-view:focus-visible { outline: 3px solid var(--cs-butter); outline-offset: 2px; }
.cs-lead { margin: -4px 0 12px; color: var(--muted); font-size: 14px; max-width: 70ch; }

/* shared shelf pieces (the Build-A-Bean shelf) */
.cs-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 8px; }
body.bm-page main.bm-wrap .cs-head h2 { margin: 0; font-size: 24px; }
.cs-count { font: 600 13px var(--f-mono, monospace); color: var(--muted); }
.cs-slots, .cs-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; }
.cs-slot { flex: none; scroll-snap-align: start; border: 2px solid var(--edge); border-radius: 999px; background: var(--surface); color: var(--text); padding: 6px 12px; font: 700 14px var(--f-body); cursor: pointer; min-height: 40px; white-space: nowrap; }
.cs-slot[aria-pressed="true"] { background: var(--cs-butter); color: #2B1B14; box-shadow: 0 3px 0 var(--edge); }
.cs-slot .n { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: var(--cs-sign); color: var(--cs-ink); font-size: 11px; }
.cs-filter { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; }
.cs-filter .cs-chips { flex: 1 1 auto; padding-bottom: 6px; }
.cs-filter input[type="search"], .cs-filter select { flex: 0 1 200px; min-width: 0; min-height: 38px; border: 2px solid var(--edge); border-radius: 999px; background: var(--surface); color: var(--text); padding: 4px 14px; font: 500 14px var(--f-body); margin-bottom: 6px; }
.cs-filter select { flex: 0 1 190px; cursor: pointer; }
.cs-check { display: inline-flex; align-items: center; gap: 6px; font: 600 14px var(--f-body); margin-bottom: 6px; cursor: pointer; white-space: nowrap; }
.cs-check input { width: 18px; height: 18px; accent-color: var(--cs-sign); }
.cs-chip { flex: none; border: 2px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); padding: 4px 11px; font: 600 13.5px var(--f-body); cursor: pointer; min-height: 36px; }
.cs-chip[aria-pressed="true"] { border-color: var(--text); background: var(--text); color: var(--bg); }
.cs-slot:focus-visible, .cs-chip:focus-visible, .cs-item:focus-visible, .cs-bean:focus-visible { outline: 3px solid var(--cs-butter); outline-offset: 2px; }
.cs-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 2px solid var(--line); }
.cs-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 20px 8px; }
.cs-more { display: flex; justify-content: center; margin-top: 12px; }

/* a trait */
.cs-item { position: relative; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 5px; cursor: pointer; text-align: left; display: grid; gap: 3px; align-content: start; box-shadow: 0 3px 0 rgba(43, 27, 20, .12); font-family: var(--f-body); }
.cs-item:hover { border-color: var(--edge); }
.cs-item[aria-pressed="true"] { border-color: var(--edge); background: var(--butter-soft, #FFE9A8); box-shadow: 0 3px 0 var(--edge); }
.cs-item[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: #2B1B14; color: #FFF6E6; font: 700 13px/22px var(--f-body); text-align: center; z-index: 2; }
.cs-item.gone { opacity: .62; }
.cs-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 9px; overflow: hidden; background: var(--surface-2); font-size: 28px; }
.cs-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cs-thumb img.under { opacity: .35; }
.cs-ph { opacity: .6; }
.cs-iname { font-size: 12.5px; font-weight: 700; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.3em; }
.cs-badges { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.cs-badges .bm-tier { font-size: 10px; }
.cs-wear { font: 800 15px var(--f-body); }
.cs-wear small { font: 600 11px var(--f-body); color: var(--muted); }
.cs-life { font-size: 11px; color: var(--muted); line-height: 1.3; }

/* the picked traits, and the bar that takes you to the BEANs */
.cs-picked { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.cs-picked:empty { display: none; }
.cs-pick { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--edge); border-radius: 999px; background: var(--butter-soft, #FFE9A8); color: #2B1B14; padding: 3px 6px 3px 10px; font: 700 13px var(--f-body); cursor: pointer; }
.cs-pick b { font-weight: 800; }
.cs-pick span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #2B1B14; color: #FFF6E6; font-size: 12px; }
.cs-link { border: 0; background: none; color: var(--text); text-decoration: underline; font: 600 13px var(--f-body); cursor: pointer; padding: 4px; }
.cs-bar { position: sticky; bottom: 10px; z-index: 6; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-top: 12px; padding: 10px 12px; border-radius: 18px; border: 3px solid var(--edge); background: var(--cs-sign); color: var(--cs-ink); box-shadow: 0 5px 0 var(--edge); }
.cs-bar[hidden] { display: none; }
.cs-bar p { margin: 0; font: 700 14px var(--f-body); color: var(--cs-ink) !important; }
body.bm-page main.bm-wrap .cs-bar .btn { min-height: 42px; }

/* a BEAN */
.cs-beans { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cs-bean { position: relative; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); padding: 6px; display: grid; gap: 4px; align-content: start; box-shadow: 0 3px 0 rgba(43, 27, 20, .12); font-family: var(--f-body); text-align: left; cursor: pointer; }
.cs-bean:hover { border-color: var(--edge); }
.cs-bean .pic { position: relative; aspect-ratio: 1; border-radius: 11px; overflow: hidden; background: var(--surface-2); }
.cs-bean .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cs-rank { position: absolute; left: 6px; top: 6px; z-index: 2; background: #2B1B14; color: #FFF6E6; border-radius: 999px; font: 800 12px var(--f-body); padding: 3px 8px; }
.cs-rank.top { background: var(--cs-gold); color: #2B1B14; }
.cs-rank.one { background: linear-gradient(90deg, #ff6fd8, #7cf, #ffe066); color: #2B1B14; }
.cs-price { position: absolute; right: 6px; bottom: 6px; z-index: 2; background: var(--cs-sign); color: var(--cs-ink); border: 2px solid #2B1B14; border-radius: 999px; font: 800 12px var(--f-body); padding: 2px 8px; text-decoration: none; }
.cs-price:hover { filter: brightness(1.1); }
.cs-bname { font: 800 13.5px var(--f-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-bsub { display: flex; justify-content: space-between; gap: 6px; font: 600 11.5px var(--f-mono, monospace); color: var(--muted); }

/* how the score works */
.cs-how ol { margin: 8px 0; padding-left: 22px; display: grid; gap: 6px; }

@media (max-width: 560px) {
  .cs-shelf { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; padding: 8px; }
  .cs-beans { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .cs-filter select, .cs-filter input[type="search"] { flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) { .cs-item, .cs-bean { transition: none; } }
#csTraits, #csBeans { scroll-margin-top: 96px; }
