.pals-toolbar {
  padding: 1rem;
  border-radius: 0.85rem;
  background: var(--surface-1);
}

.pals-toolbar > .filter-group,
.pals-toolbar > .site-search {
  width: 0;
  min-width: 0;
}

.pals-toolbar > .filter-group { flex: 3 1 0; }
.pals-toolbar > .site-search { flex: 2 1 0; }

.pals-toolbar > .filter-group {
  justify-content: center;
}

.pals-toolbar > .filter-group .filter-button {
  min-width: 0;
  flex: 1 1 0;
  text-align: center;
}

.pals-favorite-tip {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 0.75rem;
  max-width: 26rem;
  padding-left: 1rem;
}

.pals-favorite-tip > span {
  display: grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 2rem;
  place-items: center;
  border-radius: 0.45rem;
  background: rgb(255 227 109 / 0.12);
  color: #ffe36d;
  font-size: 1rem;
}

.pals-favorite-tip p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.pals-favorite-tip strong {
  color: var(--text-soft);
  font-weight: 750;
}

.work-filters,
.element-filters,
.rarity-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--content-gap);
}

.rarity-filter[data-rarity="legendary"].active {
  border-color: #9f8126;
  background: #2a220d;
  color: #f0c643;
}

.rarity-filter[data-rarity="epic"].active {
  border-color: #8240a0;
  background: #21152e;
  color: #c452ee;
}

.rarity-filter[data-rarity="rare"].active {
  border-color: #365f91;
  background: #101b2b;
  color: #4e91df;
}

.rarity-filter[data-rarity="common"].active {
  border-color: #405362;
  background: #121a21;
  color: #9aabb7;
}

.filter-hint {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.second-element-toggle {
  margin-bottom: var(--content-gap);
}

.second-element-panel {
  margin-bottom: var(--content-gap);
}

.second-element-panel .element-filters {
  margin-bottom: 0;
}

.element-filter:disabled {
  border-color: #292c31;
  background: #0c0d0f;
  color: #555a63;
  cursor: not-allowed;
  opacity: 0.55;
}

.work-filter,
.element-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.work-filter .pal-sprite-icon,
.element-filter .pal-sprite-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.pal-card {
  position: relative;
  display: flex;
  align-items: center;
  flex-direction: column;
  min-height: 10rem;
  padding: 0.65rem;
  overflow: hidden;
  cursor: pointer;
}

.pal-card:hover,
.pal-card:focus-visible {
  outline: none;
  background-color: color-mix(in srgb, var(--card-tint) 5%, var(--surface-2));
  box-shadow: none;
}

.pal-preference-marker {
  position: absolute;
  top: 0.6rem;
  left: 50%;
  color: #ffe36d;
  font-size: 0.8rem;
  letter-spacing: 0.08rem;
  transform: translateX(-50%);
}

.pal-card[data-rarity="rare"] { --card-tint: #4e91df; }
.pal-card[data-rarity="epic"] { --card-tint: #c452ee; }
.pal-card[data-rarity="legendary"] { --card-tint: #f0c643; }

.pal-card-top {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  left: 0.65rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.pal-corner-elements {
  display: grid;
  gap: 0.2rem;
}

.pal-corner-work {
  display: grid;
  grid-template-columns: max-content;
  align-content: start;
  justify-content: end;
  gap: 0.12rem;
}

.pal-corner-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: #e8ebef;
  font-size: 0.72rem;
}

.pal-sprite-icon {
  display: inline-block;
  flex: 0 0 auto;
  background-repeat: no-repeat;
}

.pal-corner-icon .pal-sprite-icon {
  width: 1.75rem;
  height: 1.75rem;
}

.pal-corner-icon strong {
  font-size: 0.85rem;
}

.pal-card-media {
  display: grid;
  align-items: center;
  justify-items: center;
  width: 4.75rem;
  height: 4.75rem;
  margin-top: 2.2rem;
  overflow: hidden;
  border: 3px solid var(--pal-element-color, #71808e);
  border-radius: 50%;
  background: #171a1d;
}

.pal-portrait-sprite {
  width: 4.25rem;
  height: 4.25rem;
  background-repeat: no-repeat;
}

.pal-card-name-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin: 0.5rem 0;
  text-align: center;
}

.pal-card-name-row .card-title {
  overflow: hidden;
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pal-card-number {
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.pal-detail-eyebrow .pal-id {
  color: #fff;
}

.pal-rarity {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  width: min(100%, 8.25rem);
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  color: var(--card-tint);
  font-size: 0.78rem;
  line-height: 1.55;
}

.pal-rarity strong {
  border-right: 0;
  text-align: center;
}

.pal-rarity span {
  padding-inline: 0.55rem;
  font-weight: 700;
}

.pal-detail-dialog {
  width: min(52rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 1.25rem;
  overflow: auto;
  border: 0;
  border-radius: 1rem;
  background: #0e1013;
  color: var(--text);
  box-shadow: 0 1.5rem 5rem rgb(0 0 0 / 0.65);
}

.pal-detail-dialog::backdrop {
  background: rgb(0 0 0 / 0.78);
  backdrop-filter: blur(3px);
}

.pal-detail-dialog[data-rarity="rare"] { --detail-tint: #4e91df; }
.pal-detail-dialog[data-rarity="epic"] { --detail-tint: #c452ee; }
.pal-detail-dialog[data-rarity="legendary"] { --detail-tint: #f0c643; }

.pal-detail-close {
  position: sticky;
  z-index: 2;
  top: 0;
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 0 -2.25rem auto;
  border: 0;
  border-radius: 50%;
  background: #17191e;
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
}

.pal-detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-right: 2.75rem;
}

.pal-detail-portrait {
  display: grid;
  flex: 0 0 auto;
  width: 6rem;
  height: 6rem;
  overflow: hidden;
  place-items: center;
  border: 3px solid var(--pal-element-color, #71808e);
  border-radius: 50%;
  background: #171a1d;
}

.pal-detail-sprite {
  width: 5.4rem;
  height: 5.4rem;
  background-repeat: no-repeat;
}

.pal-detail-eyebrow {
  color: var(--link);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pal-detail-header h2 {
  margin: 0.15rem 0;
  color: #fff;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

.pal-detail-header p,
.pal-detail-section p {
  margin: 0;
  color: var(--text-soft);
}

.pal-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.25rem 0;
}

.pal-detail-actions a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.pal-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.pal-detail-section {
  padding: 0.9rem;
  border: 0;
  border-radius: 0.75rem;
  background: rgb(255 255 255 / 0.02);
}

.pal-detail-section h3 {
  margin: 0 0 0.65rem;
  color: #fff;
  font-size: 0.9rem;
}

.pal-detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pal-detail-chip,
.pal-detail-stat {
  padding: 0.3rem 0.55rem;
  border: 0;
  border-radius: 0.4rem;
  background: color-mix(in srgb, var(--detail-tint, #71808e) 6%, transparent);
  color: var(--text-soft);
  font-size: 0.75rem;
}

.pal-detail-stat {
  display: grid;
  min-width: 4.5rem;
  text-align: center;
}

.pal-detail-stat small {
  color: var(--muted);
}

.pal-detail-stat strong {
  color: #fff;
}

.pal-breeding-power-note {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.72rem;
}

@media (max-width: 767.98px) {
  .pals-favorite-tip {
    align-self: stretch;
    max-width: none;
    padding: 0.8rem 0 0;
  }

  .work-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .element-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .work-filter,
  .element-filter {
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    padding-inline: 0.4rem;
    text-align: left;
  }

  .pal-card-media {
    width: 4rem;
    height: 4rem;
  }

  .pal-portrait-sprite {
    width: 3.6rem;
    height: 3.6rem;
  }

  .pal-detail-grid {
    grid-template-columns: 1fr;
  }

  .pal-detail-header {
    align-items: flex-start;
  }

  .pal-detail-portrait {
    width: 4.75rem;
    height: 4.75rem;
  }

  .pal-detail-sprite {
    width: 4.25rem;
    height: 4.25rem;
  }
}

@media (max-width: 1199.98px) {
  .pals-toolbar > .filter-group,
  .pals-toolbar > .site-search {
    width: 100%;
    flex: none;
  }
}
