.badges-card {
  padding: 28px;
  border: 1px solid var(--background3, var(--border));
  border-radius: 20px;
  background: var(--card);
}
.badges-collection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--background3, var(--border));
}
.badges-eyebrow {
  display: block;
  margin-bottom: 10px;
  color: var(--text2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.badges-card h1 {
  margin: 0;
  font-size: clamp(23px, 2.4vw, 30px);
  font-weight: 600;
  letter-spacing: -0.025em;
}
.badges-collection-heading p {
  margin: 10px 0 0;
  max-width: 520px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.7;
}
.badges-count {
  display: grid;
  grid-template-columns: 32px auto;
  align-items: center;
  column-gap: 12px;
  flex-shrink: 0;
  padding: 15px 20px;
  border: 1px solid var(--background3, var(--border));
  border-radius: 14px;
  background: var(--background2);
}
.badges-count > i {
  grid-row: span 2;
  font-size: 25px;
  color: var(--text2);
}
.badges-count strong {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 600;
}
.badges-count > span {
  color: var(--text2);
  font-size: 11px;
}
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 14px;
  margin-top: 26px;
}
.badge-card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 14px 20px;
  min-width: 0;
  border: 1px solid var(--background3, var(--border));
  border-radius: 16px;
  background: var(--background2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    border-color 180ms ease,
    background-color 180ms ease;
}
.badge-card:hover {
  border-color: var(--background4, var(--border));
  background: var(--background3);
}
.badge-card:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
}
.badge-card strong {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
}
.badge-earned-date {
  margin-top: auto;
  color: var(--text2);
  font-size: 11px;
  line-height: 1.5;
}
.badge-image {
  display: block;
  width: 100px;
  height: 100px;
  margin-bottom: 6px;
  transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.badge-card:hover .badge-image {
  transform: translateY(-3px) scale(1.04);
}
.badge-image img,
.badge-dialog-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.badge-image-placeholder {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 42px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--background3);
}
.badge-image .badge-image-placeholder,
.badge-dialog-image .badge-image-placeholder {
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, var(--background4), var(--background2));
  color: var(--text2);
  font-size: 42px;
}
.badge-card[draggable='true'] {
  cursor: grab;
}
.badge-card.is-dragging {
  opacity: 0.4;
}
.badge-card.is-touch-dragging {
  outline: 2px solid var(--text);
  touch-action: none;
}
.badges-collection-footer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--background3, var(--border));
  color: var(--text2);
}
.badges-collection-footer > i {
  margin-top: 4px;
  font-size: 13px;
}
.badges-hint {
  margin: 0;
  max-width: 760px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--text2);
}
.badges-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 54px 16px 40px;
  text-align: center;
}
.badges-empty-icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 24px;
  border: 1px solid var(--background3, var(--border));
  border-radius: 24px;
  background: var(--background2);
  color: var(--text2);
  font-size: 30px;
}
.badges-empty-state h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.badges-empty-state p {
  max-width: 400px;
  margin: 12px 0 0;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.8;
}
.badge-dialog {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(660px, calc(100% - 32px));
  height: fit-content;
  max-height: calc(100dvh - 40px);
  padding: 32px;
  overflow: auto;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--background4, var(--border));
  border-radius: 24px;
  box-shadow: 0 24px 90px rgb(0 0 0 / 0.35);
  z-index: 10000000;
}
.badge-dialog[open] {
  animation: badge-dialog-in 240ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.badge-dialog::backdrop {
  background: rgb(0 0 0 / 0.65);
  backdrop-filter: blur(7px);
  animation: badge-backdrop-in 240ms ease both;
}
.badge-dialog.is-closing {
  pointer-events: none;
  animation: badge-dialog-out 180ms ease both;
}
.badge-dialog.is-closing::backdrop {
  animation: badge-backdrop-out 180ms ease both;
}
.badge-dialog-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}
.badge-dialog-art {
  display: grid;
  place-items: center;
  min-height: 210px;
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 35%, var(--background3), var(--background2));
}
.badge-dialog-image {
  width: 140px;
  height: 140px;
}
.badge-dialog-image .badge-image-placeholder {
  background: transparent;
  font-size: 64px;
}
.badge-dialog-copy {
  min-width: 0;
  padding-block: 12px;
}
.badge-dialog h2 {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.badge-dialog p {
  margin: 0;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.badge-dialog-earned {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--background3, var(--border));
  font-size: 11px;
  color: var(--text2);
}
.badge-dialog-earned time {
  color: var(--text);
  font-weight: 500;
}
.badge-dialog-close {
  display: grid;
  place-items: center;
  position: absolute;
  right: 10px;
  top: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition:
    color 160ms ease,
    background-color 160ms ease;
}
.badge-dialog-close:hover {
  background: var(--background3);
  color: var(--text);
}
.badge-dialog-close:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
.badge-dialog [hidden],
.badge-admin-preview [hidden] {
  display: none !important;
}
.profile-earned-badges .badges-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.profile-earned-badges .badge-card,
.profile-earned-badges .badge-card:hover,
.profile-earned-badges .badge-card:focus-visible {
  flex: 0 0 64px;
  padding: 4px;
  gap: 0;
  border-color: transparent;
  border-radius: 10px;
  background: transparent;
}
.profile-earned-badges .badge-image {
  width: 56px;
  height: 56px;
  margin: 0;
}
.profile-earned-badges .badge-image .badge-image-placeholder {
  background: transparent;
  font-size: 30px;
}
.profile-earned-badges .badge-card strong,
.profile-earned-badges .badge-earned-date {
  display: none;
}
@keyframes badge-dialog-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes badge-dialog-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}
@keyframes badge-backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes badge-backdrop-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@media (max-width: 600px) {
  .badges-card {
    padding: 20px 16px;
  }
  .badges-collection-heading {
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 22px;
  }
  .badges-collection-heading p {
    font-size: 12px;
  }
  .badges-count {
    grid-template-columns: 1fr;
    padding: 12px;
    text-align: center;
    row-gap: 4px;
  }
  .badges-count > i {
    grid-row: auto;
    font-size: 18px;
  }
  .badges-count strong {
    font-size: 24px;
  }
  .badges-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 20px;
  }
  .badge-card {
    padding: 20px 10px 16px;
  }
  .badge-image {
    width: 80px;
    height: 80px;
  }
  .badge-image .badge-image-placeholder {
    font-size: 34px;
  }
  .badge-card strong {
    font-size: 12px;
  }
  .badges-empty-state {
    padding: 36px 0 20px;
  }
  .badge-dialog {
    padding: 36px 24px 24px;
    border-radius: 20px;
  }
  .badge-dialog-layout {
    grid-template-columns: 1fr;
    gap: 20px;
    text-align: center;
  }
  .badge-dialog-art {
    width: 100%;
    min-height: 160px;
  }
  .badge-dialog-image {
    width: 125px;
    height: 125px;
  }
  .badge-dialog-copy {
    padding: 0;
  }
  .badge-dialog h2 {
    font-size: 22px;
  }
  .badge-dialog-earned {
    justify-content: center;
  }
}
@media (prefers-reduced-motion: reduce) {
  .badge-card,
  .badge-image,
  .badge-dialog-close {
    transition: none;
  }
  .badge-card:hover .badge-image {
    transform: none;
  }
  .badge-dialog[open],
  .badge-dialog.is-closing,
  .badge-dialog::backdrop {
    animation: none;
  }
}
