/*
 * Bonkverse UI components (v0.1.3)
 * Needs tokens.css and base.css first. Every class starts with bv-.
 * index.html shows each one in all three themes with its markup.
 *
 *  1. Header and footer      7. Inputs and search
 *  2. Page layout            8. Tabs, chips, pills
 *  3. Buttons                9. Tables and pagination
 *  4. Menus                 10. Notices, status, toasts
 *  5. Skin card and grid    11. Dialogs
 *  6. Skin details          12. Empty, loading, code
 */

/* ════ 1. Header and footer ═══════════════════════════════════════════════ */

.bv-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bv-header);
  color: var(--bv-header-title);
  border-bottom: 1px solid var(--bv-outline);
}

.bv-header__inner {
  display: flex;
  align-items: center;
  gap: var(--bv-space-4);
  max-width: var(--bv-page-max);
  min-height: var(--bv-header-height);
  margin-inline: auto;
  padding-inline: var(--bv-gutter);
}

.bv-header__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--bv-space-2);
  min-height: var(--bv-target);
  color: var(--bv-header-title);
  font-size: var(--bv-text-lg);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.bv-header__brand img {
  width: 30px;
  height: 30px;
}
.bv-header__brand:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.bv-header__nav {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--bv-space-4);
}

.bv-header__links {
  display: flex;
  align-items: center;
  gap: var(--bv-space-1);
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.bv-header__links > li {
  position: relative;
}

.bv-header__link {
  display: inline-flex;
  align-items: center;
  gap: var(--bv-space-1);
  min-height: var(--bv-target);
  padding: 0 var(--bv-space-3);
  border: 0;
  border-radius: var(--bv-radius);
  background: none;
  color: var(--bv-header-title);
  font: inherit;
  font-size: var(--bv-text-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--bv-fade) ease-out, color var(--bv-fade) ease-out;
}
.bv-header__link:hover {
  background: color-mix(in srgb, var(--bv-header-title) 16%, transparent);
  text-decoration: none;
}
.bv-header__link[aria-current="page"],
.bv-header__link[aria-current="true"] {
  color: var(--bv-header-link);
  background: color-mix(in srgb, var(--bv-header-link) 14%, transparent);
}
.bv-header__link[aria-current="page"]:hover,
.bv-header__link[aria-current="true"]:hover {
  background: color-mix(in srgb, var(--bv-header-link) 26%, transparent);
}
.bv-header__link svg {
  width: 16px;
  height: 16px;
}
/* Only the chevron turns when a menu opens, never the other icons. */
.bv-header__link :is(.bv-chevron, .lucide-chevron-down) {
  transition: transform var(--bv-fade) ease-out;
}
[aria-expanded="true"] > :is(.bv-chevron, .lucide-chevron-down) {
  transform: rotate(180deg);
}

/* Signed in: the name goes to your profile; the chevron next to it opens
   the account menu. */
.bv-header__account {
  display: inline-flex;
  align-items: center;
}
.bv-header__account > .bv-header__link:first-child {
  padding-right: var(--bv-space-1);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.bv-header__account > .bv-header__link + .bv-header__link {
  min-width: var(--bv-target);
  padding: 0 var(--bv-space-2);
  justify-content: center;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.bv-header__account svg {
  width: 18px;
  height: 18px;
}

.bv-header__end {
  display: flex;
  align-items: center;
  gap: var(--bv-space-2);
}

.bv-header .bv-header__menu-btn {
  display: none;
  margin-left: auto;
  color: var(--bv-header-title);
  border-color: color-mix(in srgb, var(--bv-header-title) 35%, transparent);
  background: transparent;
}

/* Theme picker: a labeled native select, sized for the header */
.bv-theme-picker {
  display: inline-flex;
  align-items: center;
  gap: var(--bv-space-2);
  color: var(--bv-header-meta);
  font-size: var(--bv-text-xs);
}
.bv-theme-picker select {
  min-height: var(--bv-target);
  padding: 0 28px 0 var(--bv-space-3);
  border: 1px solid color-mix(in srgb, var(--bv-header-title) 35%, transparent);
  border-radius: var(--bv-radius);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b3bec4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--bv-header-title);
  font: inherit;
  font-size: var(--bv-text-sm);
  font-weight: 500;
  appearance: none;
  cursor: pointer;
}
.bv-theme-picker select option {
  background: var(--bv-card);
  color: var(--bv-text);
}

/* Phones and small tablets: the links fold into the Menu button */
@media (max-width: 899px) {
  .bv-header__inner {
    flex-wrap: wrap;
  }
  .bv-header .bv-header__menu-btn {
    display: inline-flex;
  }
  .bv-header__nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: var(--bv-space-2);
    padding-bottom: var(--bv-space-4);
  }
  .bv-header__nav[data-open] {
    display: flex;
    /* A long menu on a short (landscape) phone scrolls inside the header
       instead of running off the bottom of a sticky bar. */
    max-height: calc(100vh - var(--bv-header-height));
    max-height: calc(100dvh - var(--bv-header-height));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .bv-header__links {
    flex-direction: column;
    align-items: stretch;
    margin: 0;
  }
  .bv-header__link {
    width: 100%;
    justify-content: space-between;
  }
  /* Menus open in place inside the phone menu (it scrolls, so a floating
     menu would be clipped). */
  .bv-header__nav .bv-menu {
    position: static;
    min-width: 0;
    margin: var(--bv-space-1) 0 var(--bv-space-2) var(--bv-space-4);
    box-shadow: none;
  }
  .bv-header__end .bv-dropdown {
    display: contents; /* its menu wraps onto a full-width line below */
  }
  .bv-header__account > .bv-header__link {
    width: auto;
  }
  .bv-header__end .bv-menu {
    flex-basis: 100%;
    margin-left: 0;
  }
  .bv-header__end {
    flex-wrap: wrap;
    justify-content: space-between;
    padding-top: var(--bv-space-2);
    border-top: 1px solid color-mix(in srgb, var(--bv-header-title) 20%, transparent);
  }
}

.bv-footer {
  margin-top: var(--bv-space-8);
  border-top: 1px solid var(--bv-outline);
  color: var(--bv-muted);
  font-size: var(--bv-text-sm);
}
.bv-footer__inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--bv-space-6);
  max-width: var(--bv-page-max);
  margin-inline: auto;
  padding: var(--bv-space-6) var(--bv-gutter);
}
.bv-footer h2 {
  margin-bottom: var(--bv-space-2);
  color: var(--bv-text);
  font-size: var(--bv-text-sm);
  line-height: var(--bv-leading-sm);
}
.bv-footer ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.bv-footer li a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
}
.bv-footer__note {
  grid-column: 1 / -1;
  font-size: var(--bv-text-xs);
}

/* ════ 2. Page layout ═════════════════════════════════════════════════════ */

.bv-main {
  max-width: var(--bv-page-max);
  margin-inline: auto;
  padding: var(--bv-space-6) var(--bv-gutter) 0;
}

.bv-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--bv-space-4);
  margin-bottom: var(--bv-space-6);
}
.bv-page-header__text {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bv-space-2);
  max-width: 68ch;
}
.bv-page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bv-space-2);
}

.bv-eyebrow {
  color: var(--bv-muted);
  font-size: var(--bv-text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bv-lead {
  color: var(--bv-muted);
  font-size: var(--bv-text-lg);
  line-height: 1.45;
}

.bv-back {
  display: inline-flex;
  align-items: center;
  gap: var(--bv-space-1);
  min-height: var(--bv-target);
  font-size: var(--bv-text-sm);
  font-weight: 600;
  text-decoration: none;
}
.bv-back:hover {
  text-decoration: underline;
}

.bv-card {
  padding: var(--bv-space-5);
  border: 1px solid var(--bv-outline);
  border-radius: var(--bv-radius);
  background: var(--bv-card);
}
.bv-card:not(.bv-form) > * + * {
  margin-top: var(--bv-space-3);
}
.bv-card__title {
  display: flex;
  align-items: center;
  gap: var(--bv-space-2);
  font-size: var(--bv-text-lg);
  line-height: var(--bv-leading-lg);
}

.bv-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bv-space-6);
}

/* ════ 3. Buttons ═════════════════════════════════════════════════════════ */
/*
 * .bv-btn            secondary: card fill, control border
 * .bv-btn--primary   the brown main action; one per screen or card
 * .bv-btn--ghost     no fill or border, teal text (Copy link, Quickstart)
 * .bv-btn--danger    solid red, white text: does something you can't undo
 *                    (Delete, Revoke); the confirm button of a delete dialog
 * .bv-btn--danger-outline  red text on a red tint (Report): a warning, not
 *                    the destructive step itself
 * .bv-btn--icon      44 × 44 square, needs aria-label
 * States: :hover, :active (press), :focus-visible, :disabled,
 *         aria-pressed="true" (selected), aria-busy="true" (pending)
 * Every state reads in every theme without color alone: hover changes the
 * fill and darkens the border to the text color, selected adds a 2 px teal
 * border, disabled fades and dashes the border.
 */

.bv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--bv-space-2);
  min-height: var(--bv-target);
  padding: 0 var(--bv-space-4);
  border: 1px solid var(--bv-control);
  border-radius: var(--bv-radius);
  background: var(--bv-card);
  color: var(--bv-text);
  font: inherit;
  font-size: var(--bv-text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--bv-fade) ease-out,
    border-color var(--bv-fade) ease-out,
    color var(--bv-fade) ease-out,
    transform var(--bv-press) ease-out;
}
.bv-btn:hover {
  border-color: var(--bv-text);
  background: var(--bv-hover);
  text-decoration: none;
}
.bv-btn:active:not(:disabled, [aria-disabled="true"]) {
  transform: scale(0.98);
}
.bv-btn svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.bv-btn--primary {
  border-color: var(--bv-action-border);
  background: var(--bv-action);
  color: var(--bv-action-ink);
}
.bv-btn--primary:hover {
  border-color: var(--bv-action-ink);
  background: var(--bv-action-hover);
}
.bv-btn--primary:active {
  background: var(--bv-action-pressed);
}

.bv-btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--bv-link);
  padding-inline: var(--bv-space-3);
}
.bv-btn--ghost:hover {
  border-color: var(--bv-link);
  background: color-mix(in srgb, var(--bv-link) 12%, transparent);
}

.bv-btn--danger {
  border-color: var(--bv-danger-border);
  background: var(--bv-danger-solid);
  color: var(--bv-danger-ink);
}
.bv-btn--danger:hover {
  border-color: var(--bv-danger-ink);
  background: var(--bv-danger-solid-hover);
}
.bv-btn--danger:active {
  background: var(--bv-danger-solid-pressed);
}

.bv-btn--danger-outline {
  border-color: var(--bv-danger);
  background: var(--bv-danger-surface);
  color: var(--bv-danger);
}
.bv-btn--danger-outline:hover {
  border-color: var(--bv-danger);
  background: var(--bv-danger-surface);
  box-shadow: inset 0 0 0 1px var(--bv-danger);
}

.bv-btn--icon {
  width: var(--bv-target);
  padding: 0;
}

.bv-btn--block {
  width: 100%;
}

.bv-btn[aria-pressed="true"] {
  border-color: var(--bv-link);
  background: var(--bv-selected);
  box-shadow: inset 0 0 0 1px var(--bv-link);
}

.bv-btn:disabled,
.bv-btn[aria-disabled="true"] {
  border-style: dashed;
  opacity: 0.55;
  cursor: not-allowed;
}
.bv-btn:disabled:hover,
.bv-btn[aria-disabled="true"]:hover {
  border-color: var(--bv-control);
  background: var(--bv-card);
}
.bv-btn--ghost:disabled:hover,
.bv-btn--ghost[aria-disabled="true"]:hover {
  border-color: transparent;
  background: transparent;
}
.bv-btn--primary:disabled:hover,
.bv-btn--primary[aria-disabled="true"]:hover {
  border-color: var(--bv-action-border);
  background: var(--bv-action);
}
.bv-btn--danger:disabled:hover,
.bv-btn--danger[aria-disabled="true"]:hover {
  border-color: var(--bv-danger-border);
  background: var(--bv-danger-solid);
}

/* Pending keeps full opacity and a waiting cursor: it's working, not off. */
.bv-btn[aria-busy="true"] {
  opacity: 1;
  cursor: progress;
}

/* ════ 4. Menus (Open in, ···, Tools, account) ════════════════════════════ */
/*
 * <div class="bv-dropdown">
 *   <button class="bv-btn" aria-expanded="false" aria-controls="m1" data-bv-toggle>…</button>
 *   <div class="bv-menu" id="m1" hidden>…items…</div>
 * </div>
 * ui.js opens one at a time, closes on Escape or outside click and returns focus.
 */

.bv-dropdown {
  position: relative;
  display: inline-block;
}

.bv-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 200px;
  padding: var(--bv-space-1);
  border: 1px solid var(--bv-control);
  border-radius: var(--bv-radius);
  background: var(--bv-card);
  box-shadow: var(--bv-shadow);
  animation: bv-rise var(--bv-enter) var(--bv-ease-out);
}
.bv-menu--end {
  left: auto;
  right: 0;
}
.bv-menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bv-menu__item {
  display: flex;
  align-items: center;
  gap: var(--bv-space-2);
  width: 100%;
  min-height: var(--bv-target);
  padding: 0 var(--bv-space-3);
  border: 0;
  border-radius: var(--bv-radius-sm);
  background: none;
  color: var(--bv-text);
  font: inherit;
  font-size: var(--bv-text-sm);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.bv-menu__item:hover {
  background: var(--bv-hover);
  text-decoration: none;
}
.bv-menu__item svg {
  width: 16px;
  height: 16px;
  color: var(--bv-muted);
}
.bv-menu__item--danger {
  color: var(--bv-danger);
}
.bv-menu__item--danger:hover {
  background: var(--bv-danger-surface);
}
.bv-menu__item--danger svg {
  color: currentColor;
}
.bv-menu__divider {
  height: 1px;
  margin: var(--bv-space-1) 0;
  background: var(--bv-outline);
}

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

/* ════ 5. Skin card and grid ══════════════════════════════════════════════ */
/*
 * Search is for fast decisions: artwork, name, creator, Favorite and Wear
 * one tap away, and a labeled "Skin details" link. Guide sections 01, 04, 05.
 */

.bv-skin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bv-space-4);
  max-width: 1228px;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 600px) {
  .bv-skin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--bv-space-5); }
}
@media (min-width: 900px) {
  .bv-skin-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
  .bv-skin-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.bv-skin-grid > li {
  display: flex;
  flex-direction: column;
}
.bv-skin-grid > li > .bv-skin-card {
  flex: 1;
}

.bv-skin-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--bv-outline);
  border-radius: var(--bv-radius);
  background: var(--bv-card);
}

.bv-skin-card__stage {
  position: relative;
  display: flex;
  justify-content: center;
  border-bottom: 1px solid var(--bv-divider);
  background: var(--bv-thumb);
}

/* The art button covers the whole stage (so "Enlarge" and the space around
   the circle open it too); Favorite sits on top of it, top right. */
.bv-skin-card__art,
.bv-skin-detail__art {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--bv-muted);
  font: inherit;
  cursor: zoom-in;
}
/* Only the image moves: a transform on the button would make it the box the
   "Enlarge" label is placed in, and the label would jump mid-click. */
.bv-skin-card__art img,
.bv-skin-art {
  display: block;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: contain;
  transition: transform var(--bv-fade) var(--bv-ease-out);
}
.bv-skin-card__art:hover img,
.bv-skin-detail__art:hover .bv-skin-art {
  transform: scale(1.05);
}
.bv-skin-card__art:active img,
.bv-skin-detail__art:active .bv-skin-art {
  transform: scale(0.97);
}

.bv-enlarge {
  position: absolute;
  right: var(--bv-space-3);
  bottom: var(--bv-space-2);
  pointer-events: none; /* the art button underneath takes the click */
  color: var(--bv-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}
.bv-skin-card__art:hover .bv-enlarge,
.bv-skin-detail__art:hover .bv-enlarge {
  color: var(--bv-link);
  text-decoration: underline;
}

/* Missing or broken artwork keeps its circle */
.bv-skin-art--missing {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 1px dashed var(--bv-control);
  border-radius: 50%;
  color: var(--bv-muted);
  font-size: var(--bv-text-xs);
  text-align: center;
}

.bv-skin-card__art {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: var(--bv-space-3);
  border-radius: 0;
}
.bv-skin-card__stage > :not(.bv-skin-card__art, .bv-skin-card__fav) {
  margin: var(--bv-space-3); /* missing art, loading circle */
}
.bv-skin-card__art:focus-visible {
  outline-offset: -2px;
}
.bv-skin-card__fav {
  position: absolute;
  z-index: 1;
  top: var(--bv-space-1);
  right: var(--bv-space-1);
}

.bv-skin-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--bv-space-1);
  padding: var(--bv-space-3);
}

.bv-skin-card__title {
  color: var(--bv-heading);
  font-size: var(--bv-text-lg);
  line-height: var(--bv-leading-lg);
  font-weight: 700;
}

.bv-creator {
  color: var(--bv-muted);
  font-size: var(--bv-text-xs);
  line-height: var(--bv-leading-xs);
}
.bv-creator a {
  color: inherit;
  font-weight: 500;
}
.bv-creator a:hover {
  color: var(--bv-link);
}

.bv-skin-card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--bv-space-2);
  margin-top: auto;
  padding-top: var(--bv-space-2);
}

.bv-details-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: var(--bv-target);
  font-size: var(--bv-text-sm);
  font-weight: 600;
  text-decoration: none;
}
.bv-details-link:hover {
  text-decoration: underline;
}

/* Wear: stable width through Ready → Applying… → ✓ Applied / Retry */
.bv-wear {
  min-width: 104px;
}
.bv-wear[data-state="success"] {
  border-color: var(--bv-control);
  background: var(--bv-success);
  color: var(--bv-text);
  animation: bv-fade-in var(--bv-enter) ease-out;
}

/* Favorite: outline star and count, then a filled gold star */
.bv-fav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--bv-space-1);
  min-width: var(--bv-target);
  min-height: var(--bv-target);
  padding: 0 var(--bv-space-2);
  border: 0;
  border-radius: var(--bv-radius);
  background: none;
  color: var(--bv-muted);
  font: inherit;
  font-size: var(--bv-text-xs);
  font-weight: 600;
  cursor: pointer;
}
.bv-fav:hover {
  color: var(--bv-text);
}
.bv-fav svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
}
.bv-fav[aria-pressed="true"] {
  color: var(--bv-gold);
}
.bv-fav[aria-pressed="true"] svg {
  fill: currentColor;
  animation: bv-star var(--bv-pop) ease-out;
}
span.bv-fav {
  cursor: default;
}

@keyframes bv-star {
  45% { transform: scale(1.27) rotate(-12deg); }
  to { transform: none; }
}
@keyframes bv-fade-in {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* Loading card: reserves the real card's geometry */
.bv-skin-card--loading .bv-skin-card__stage {
  height: 137px;
}
.bv-skin-card--loading .bv-skeleton--circle {
  width: 112px;
  height: 112px;
}

/* ════ 6. Skin details ════════════════════════════════════════════════════ */
/*
 * Details is for deeper actions: the art sits on the page (no backing),
 * votes beside Wear, and sharing and tools in a compact second row.
 */

.bv-skin-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bv-space-4);
  max-width: 560px;
  margin-inline: auto;
}

.bv-skin-detail__art {
  position: relative;
  justify-self: center;
  padding: 0 0 var(--bv-space-5);
}
.bv-skin-detail__art .bv-skin-art,
.bv-skin-detail__art .bv-skin-art--missing {
  width: 160px;
  height: 160px;
}
.bv-skin-detail__art .bv-enlarge {
  right: 0;
  bottom: 0;
}

.bv-skin-detail__content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bv-space-4);
  align-content: start;
}

.bv-skin-detail__title {
  font-size: var(--bv-text-xl);
  line-height: var(--bv-leading-xl);
}

/* Votes, then Wear. Wear is the main action but doesn't need the whole row. */
.bv-skin-detail__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bv-space-2);
}
.bv-skin-detail__actions .bv-wear {
  min-width: 160px;
}

.bv-votes {
  display: inline-flex;
  gap: var(--bv-space-2);
}
.bv-vote {
  min-width: 64px;
  font-variant-numeric: tabular-nums;
}

/* Everything else is one tap away as a labeled button: no menus. */
.bv-skin-detail__tools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bv-space-1) var(--bv-space-2);
  padding-top: var(--bv-space-3);
  border-top: 1px solid var(--bv-outline);
}
.bv-skin-detail__tools .bv-btn {
  padding-inline: var(--bv-space-3);
}

@media (min-width: 900px) {
  .bv-skin-detail {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    column-gap: var(--bv-space-12);
    max-width: 880px;
  }
  .bv-skin-detail > .bv-back {
    grid-column: 1 / -1;
  }
  .bv-skin-detail__art .bv-skin-art,
  .bv-skin-detail__art .bv-skin-art--missing {
    width: 240px;
    height: 240px;
  }
}

/* ════ 7. Inputs and search ═══════════════════════════════════════════════ */

.bv-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bv-space-4);
  max-width: 480px;   /* fields wider than this are hard to scan */
}
.bv-form > .bv-btn,
.bv-form > .bv-check {
  justify-self: start;
}

.bv-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bv-space-1);
  max-width: 480px;
}

.bv-label {
  color: var(--bv-text);
  font-size: var(--bv-text-sm);
  font-weight: 600;
}

.bv-hint {
  color: var(--bv-muted);
  font-size: var(--bv-text-xs);
  line-height: var(--bv-leading-xs);
}

.bv-error {
  color: var(--bv-danger);
  font-size: var(--bv-text-xs);
  font-weight: 500;
  line-height: var(--bv-leading-xs);
}

.bv-input,
.bv-select,
.bv-textarea {
  width: 100%;
  min-height: var(--bv-target);
  padding: 0 var(--bv-space-3);
  border: 1px solid var(--bv-control);
  border-radius: var(--bv-radius);
  background: var(--bv-input);
  color: var(--bv-text);
  font: inherit;
  font-size: var(--bv-text-input);
}
.bv-textarea {
  min-height: 96px;
  padding: var(--bv-space-2) var(--bv-space-3);
  resize: vertical;
}
.bv-input::placeholder,
.bv-textarea::placeholder {
  color: var(--bv-muted);
  opacity: 0.85;
}
.bv-input:focus-visible,
.bv-select:focus-visible,
.bv-textarea:focus-visible {
  outline-offset: 0;
  border-color: var(--bv-link);
}
.bv-input[aria-invalid="true"],
.bv-textarea[aria-invalid="true"] {
  border-color: var(--bv-danger);
}
.bv-input:disabled {
  opacity: 0.55;
}

.bv-select {
  padding-right: 36px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2383949e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.bv-check {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--bv-space-2);
  min-height: var(--bv-target);
  padding-top: 11px;
  font-size: var(--bv-text-sm);
  cursor: pointer;
}
.bv-check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--bv-link);
}

/* Search: the action sits inside the field, as in the guide */
.bv-search {
  display: flex;
  min-width: 0;
  max-width: 480px;
  align-items: stretch;
  border: 1px solid var(--bv-control);
  border-radius: var(--bv-radius);
  background: var(--bv-input);
}
.bv-search:focus-within {
  border-color: var(--bv-link);
  outline: 2px solid var(--bv-link);
  outline-offset: 2px;
}
.bv-search input {
  flex: 1;
  width: 0;          /* no intrinsic width: it fills what's left, however narrow */
  min-width: 0;
  min-height: var(--bv-target);
  padding: 0 var(--bv-space-3);
  border: 0;
  border-radius: var(--bv-radius) 0 0 var(--bv-radius);
  background: transparent;
  color: var(--bv-text);
  font: inherit;
  font-size: var(--bv-text-input);
}
.bv-search input:focus-visible {
  outline: none;
}
.bv-search input::placeholder {
  color: var(--bv-muted);
  opacity: 0.85;
}
.bv-search input::-webkit-search-cancel-button {
  filter: grayscale(1);
}
.bv-search button {
  flex: none;
  min-width: 80px;
  min-height: var(--bv-target);
  margin: 0;
  padding: 0 var(--bv-space-3);
  border: 0;
  border-left: 1px solid var(--bv-outline);
  border-radius: 0 calc(var(--bv-radius) - 1px) calc(var(--bv-radius) - 1px) 0;
  background: var(--bv-search-action);
  color: var(--bv-link);
  font: inherit;
  font-size: var(--bv-text-sm);
  font-weight: 700;
  cursor: pointer;
}
.bv-search button:hover {
  background: var(--bv-search-action-hover);
}

/* ════ 8. Tabs, chips, pills ══════════════════════════════════════════════ */

/* Section tabs are links between pages (Search · New · Categories …) */
.bv-tabs {
  display: flex;
  gap: var(--bv-space-1);
  margin-bottom: var(--bv-space-6);
  overflow-x: auto;
  border-bottom: 1px solid var(--bv-outline);
  scrollbar-width: thin;
}
.bv-tab {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: var(--bv-target);
  padding: 0 var(--bv-space-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--bv-muted);
  font-size: var(--bv-text-sm);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.bv-tab:hover {
  border-bottom-color: var(--bv-control);
  color: var(--bv-text);
  text-decoration: none;
}
.bv-tab[aria-current="page"],
.bv-tab[aria-selected="true"] {
  color: var(--bv-link);
  border-bottom-color: var(--bv-link);
}

/* Filter chips toggle with aria-pressed */
.bv-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bv-space-2);
}
.bv-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--bv-space-1);
  min-height: 36px;
  padding: 0 var(--bv-space-3);
  border: 1px solid var(--bv-control);
  border-radius: var(--bv-radius-pill);
  background: transparent;
  color: var(--bv-text);
  font: inherit;
  font-size: var(--bv-text-xs);
  font-weight: 600;
  cursor: pointer;
  /* 36 px chips still get a 44 px target */
  position: relative;
}
.bv-chip::after {
  content: "";
  position: absolute;
  inset: -4px 0;
}
.bv-chip:hover {
  border-color: var(--bv-text);
  background: var(--bv-hover);
}
.bv-chip[aria-pressed="true"],
.bv-chip[aria-current]:not([aria-current="false"]) {
  border-color: var(--bv-link);
  background: var(--bv-selected);
  box-shadow: inset 0 0 0 1px var(--bv-link);
  color: var(--bv-text);
}
.bv-chip:disabled,
.bv-chip[aria-disabled="true"] {
  border-style: dashed;
  background: transparent;
  opacity: 0.55;
  cursor: not-allowed;
}
.bv-chip[aria-pressed="true"]:hover,
.bv-chip[aria-current]:not([aria-current="false"]):hover,
.bv-btn[aria-pressed="true"]:hover {
  box-shadow: inset 0 0 0 2px var(--bv-link);
}
.bv-chip[aria-pressed="true"]::before {
  content: "✓";
  color: var(--bv-link);
}

/* Small read-only labels (Partner, Staff) */
.bv-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--bv-space-2);
  border: 1px solid var(--bv-control);
  border-radius: var(--bv-radius-pill);
  background: var(--bv-hover);
  color: var(--bv-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  vertical-align: middle;
}
.bv-pill--accent {
  border-color: var(--bv-link);
  background: var(--bv-selected);
  color: var(--bv-text);
}

/* ════ 9. Tables and pagination ═══════════════════════════════════════════ */

.bv-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--bv-outline);
  border-radius: var(--bv-radius);
  background: var(--bv-card);
}
.bv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--bv-text-sm);
}
.bv-table th,
.bv-table td {
  padding: var(--bv-space-3) var(--bv-space-4);
  border-bottom: 1px solid var(--bv-outline);
  text-align: left;
  vertical-align: middle;
}
.bv-table th {
  color: var(--bv-muted);
  font-size: var(--bv-text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.bv-table tbody tr:last-child td {
  border-bottom: 0;
}
.bv-table tbody tr:hover {
  background: var(--bv-hover);
}
.bv-table .bv-num {
  text-align: right;
}
.bv-table__rank {
  width: 1%;
  color: var(--bv-muted);
  font-variant-numeric: tabular-nums;
}

.bv-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--bv-space-2);
  margin-top: var(--bv-space-6);
  font-size: var(--bv-text-sm);
}
.bv-pagination__status {
  color: var(--bv-muted);
  padding-inline: var(--bv-space-2);
}

/* ════ 10. Notices, status, toasts ════════════════════════════════════════ */

.bv-notice {
  display: flex;
  max-width: 720px;   /* a readable line; inside a narrower card it just fills it */
  align-items: flex-start;
  gap: var(--bv-space-3);
  padding: var(--bv-space-3) var(--bv-space-4);
  border: 1px solid var(--bv-outline);
  border-left: 3px solid var(--bv-link);
  border-radius: var(--bv-radius);
  background: var(--bv-card);
  font-size: var(--bv-text-sm);
  line-height: var(--bv-leading-sm);
}
.bv-notice svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--bv-link);
}
.bv-notice--success {
  border-left-color: var(--bv-link);
  background: var(--bv-success);
}
.bv-notice--danger {
  border-color: var(--bv-danger);
  border-left-color: var(--bv-danger);
  background: var(--bv-danger-surface);
}
.bv-notice--danger svg {
  color: var(--bv-danger);
}

/* Inline status under an action row (Wear feedback). Use role="status". */
.bv-status {
  min-height: var(--bv-leading-xs);
  color: var(--bv-muted);
  font-size: var(--bv-text-xs);
  line-height: var(--bv-leading-xs);
}
.bv-status:empty {
  display: none;
}
.bv-status--success {
  color: var(--bv-link);
}
.bv-status--error {
  color: var(--bv-danger);
}

.bv-toasts {
  position: fixed;
  left: 50%;
  bottom: var(--bv-space-4);
  z-index: 80;
  display: grid;
  gap: var(--bv-space-2);
  width: min(420px, calc(100vw - 2 * var(--bv-space-4)));
  transform: translateX(-50%);
  pointer-events: none;
}
.bv-toast {
  display: flex;
  align-items: center;
  gap: var(--bv-space-3);
  padding: var(--bv-space-3) var(--bv-space-4);
  border: 1px solid var(--bv-control);
  border-radius: var(--bv-radius);
  background: var(--bv-card);
  box-shadow: var(--bv-shadow);
  color: var(--bv-text);
  font-size: var(--bv-text-sm);
  pointer-events: auto;
  animation: bv-rise var(--bv-enter) var(--bv-ease-out);
}
.bv-toast--success {
  border-color: var(--bv-link);
}
.bv-toast--error {
  border-color: var(--bv-danger);
}
.bv-toast__close {
  margin-left: auto;
}

/* ════ 11. Dialogs ════════════════════════════════════════════════════════ */
/*
 * Native <dialog class="bv-dialog"> opened with showModal(): focus stays
 * inside, Escape closes, and ui.js returns focus to the opener.
 */

.bv-dialog {
  width: min(480px, calc(100vw - 2 * var(--bv-space-4)));
  max-height: calc(100vh - 2 * var(--bv-space-4));
  padding: 0;
  border: 1px solid var(--bv-control);
  border-radius: var(--bv-radius);
  background: var(--bv-card);
  box-shadow: var(--bv-shadow);
  color: var(--bv-text);
}
.bv-dialog[open] {
  animation: bv-rise var(--bv-enter) var(--bv-ease-out);
}
.bv-dialog::backdrop {
  background: var(--bv-backdrop);
}
.bv-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bv-space-3);
  padding: var(--bv-space-2) var(--bv-space-2) 0 var(--bv-space-5);
}
.bv-dialog__title {
  font-size: var(--bv-text-lg);
  line-height: var(--bv-leading-lg);
}
.bv-dialog__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bv-space-3);
  padding: var(--bv-space-3) var(--bv-space-5) var(--bv-space-5);
}
.bv-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--bv-space-2);
  padding-top: var(--bv-space-2);
}

/* Enlarged skin: 264 px art in a 370 px dialog, scaled down to fit */
.bv-dialog--zoom {
  width: min(370px, calc(100vw - 2 * var(--bv-space-4)));
}
.bv-dialog--zoom .bv-dialog__body {
  justify-items: center;
}
.bv-dialog--zoom img {
  width: min(264px, 70vw, 60vh);
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: contain;
}
.bv-dialog__tools {
  display: flex;
  align-items: center;
  gap: var(--bv-space-1);
}
/* "Full size": the dialog takes the screen and shows the image as large as
   it can, up to its real size. */
.bv-dialog--zoom.is-full {
  width: calc(100vw - 2 * var(--bv-space-4));
  max-width: none;
  height: calc(100vh - 2 * var(--bv-space-4));
  max-height: none;
}
.bv-dialog--zoom.is-full .bv-dialog__body {
  height: calc(100% - 60px);
  align-content: center;
}
.bv-dialog--zoom.is-full img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}

/* ════ 12. Empty, loading, code ═══════════════════════════════════════════ */

.bv-empty {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: var(--bv-space-2);
  padding: var(--bv-space-12) var(--bv-space-4);
  border: 1px dashed var(--bv-outline);
  border-radius: var(--bv-radius);
  text-align: center;
}
.bv-empty svg {
  width: 32px;
  height: 32px;
  color: var(--bv-muted);
}
.bv-empty__title {
  font-size: var(--bv-text-lg);
  line-height: var(--bv-leading-lg);
}
.bv-empty p {
  max-width: 44ch;
  color: var(--bv-muted);
}
.bv-empty .bv-btn {
  margin-top: var(--bv-space-2);
}

.bv-skeleton {
  display: block;
  border-radius: var(--bv-radius-sm);
  background: linear-gradient(
    90deg,
    var(--bv-thumb) 0%,
    color-mix(in srgb, var(--bv-outline) 60%, var(--bv-thumb)) 50%,
    var(--bv-thumb) 100%
  );
  background-size: 200% 100%;
  animation: bv-shimmer 1.4s ease-in-out infinite;
}
.bv-skeleton--circle {
  border-radius: 50%;
}
.bv-skeleton--line {
  height: 12px;
}
@keyframes bv-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bv-skeleton { animation: none; }
}

/* Loader: 8 dots, the brightest one going round. Only while really waiting. */
.bv-loader {
  display: inline-flex;
  align-items: center;
  gap: var(--bv-space-3);
  color: var(--bv-muted);
  font-size: var(--bv-text-sm);
}
.bv-loader__ring {
  position: relative;
  width: 28px;
  height: 28px;
}
.bv-loader__ring i {
  position: absolute;
  top: 0;
  left: 12px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--bv-muted);
  opacity: 0.3;
  transform-origin: 2px 14px;
  animation: bv-loader 1s linear infinite;
}
.bv-loader__ring i:nth-child(1) { transform: rotate(0deg); animation-delay: -0.875s; }
.bv-loader__ring i:nth-child(2) { transform: rotate(45deg); animation-delay: -0.75s; }
.bv-loader__ring i:nth-child(3) { transform: rotate(90deg); animation-delay: -0.625s; }
.bv-loader__ring i:nth-child(4) { transform: rotate(135deg); animation-delay: -0.5s; }
.bv-loader__ring i:nth-child(5) { transform: rotate(180deg); animation-delay: -0.375s; }
.bv-loader__ring i:nth-child(6) { transform: rotate(225deg); animation-delay: -0.25s; }
.bv-loader__ring i:nth-child(7) { transform: rotate(270deg); animation-delay: -0.125s; }
.bv-loader__ring i:nth-child(8) { transform: rotate(315deg); animation-delay: 0s; }
@keyframes bv-loader {
  0% { opacity: 1; background: var(--bv-link); }
  60%, 100% { opacity: 0.3; background: var(--bv-muted); }
}
@media (prefers-reduced-motion: reduce) {
  .bv-loader__ring i { animation: none; opacity: 0.6; }
}

/* Code block with a copy button (docs, developer portal).
   Optional bar on top: <div class="bv-code__bar"><span>curl</span><button…>Copy</button></div> */
.bv-code {
  position: relative;
  border: 1px solid var(--bv-outline);
  border-radius: var(--bv-radius);
  background: var(--bv-thumb);
}
.bv-code pre {
  margin: 0;
  padding: var(--bv-space-4);
  padding-right: 88px;
  overflow-x: auto;
  color: var(--bv-text);
  font-size: 13px;
  line-height: 1.6;
}
.bv-code .bv-btn {
  position: absolute;
  top: var(--bv-space-1);
  right: var(--bv-space-1);
}

.bv-code__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bv-space-2);
  padding: 0 var(--bv-space-1) 0 var(--bv-space-4);
  border-bottom: 1px solid var(--bv-outline);
  color: var(--bv-muted);
  font-size: var(--bv-text-xs);
  font-weight: 600;
}
.bv-code__bar .bv-btn {
  position: static;
}
.bv-code__bar + pre {
  padding-right: var(--bv-space-4);
}

/* Tabs that switch panels on the page (code languages): ui.js wires any
   [role="tablist"][data-bv-tabs]; the choice is remembered per data-bv-tabs name. */
.bv-tabs [role="tab"] {
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font: inherit;
  font-size: var(--bv-text-sm);
  font-weight: 600;
  cursor: pointer;
}
.bv-tabs [role="tab"]:hover {
  border-bottom-color: var(--bv-control);
}
.bv-tabs [role="tab"][aria-selected="true"] {
  border-bottom-color: var(--bv-link);
}
.bv-code .bv-tabs {
  margin: 0;
  padding: 0 var(--bv-space-2);
  border-bottom: 1px solid var(--bv-outline);
}
