.em-toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 14px;
}
.em-toolbar form { margin: 0; }
.em-toolbar .fo-filter-row { margin-top: 12px; }
.em-toolbar .fo-filter-row:first-child { margin-top: 0; }
.em-toolbar .btn { align-self: end; }
.em-search-row { margin-bottom: 12px; }
.em-search {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
}

.em-count { margin: 10px 0 0 2px; font-size: 12px; color: var(--muted); }
.em-count strong { color: var(--accent); font-size: 13px; }

.em-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 10px;
  align-items: start;
}

.em-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.em-card .raritypill.rarity-normal  { --c: var(--r-normal); }
.em-card .raritypill.rarity-special { --c: var(--r-special); }
.em-card .raritypill.rarity-rare    { --c: var(--r-rare); }
.em-card .raritypill.rarity-master  { --c: var(--r-master); }
.em-card .raritypill.rarity-super   { --c: var(--r-super); }
.em-card .raritypill.rarity-mythic  { --c: var(--r-mythic); }
.em-card .em-expand.rarity-normal  { --c: var(--r-normal); }
.em-card .em-expand.rarity-special { --c: var(--r-special); }
.em-card .em-expand.rarity-rare    { --c: var(--r-rare); }
.em-card .em-expand.rarity-master  { --c: var(--r-master); }
.em-card .em-expand.rarity-super   { --c: var(--r-super-2); }
.em-card .em-expand.rarity-mythic  { --c: var(--r-mythic); }

.em-actions {
  margin: 12px 0 0;
  display: flex;
  gap: 8px;
  align-items: center;
}
.em-actions .btn { text-decoration: none; }
.em-card summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-lg);
}
.em-card summary::-webkit-details-marker { display: none; }
.em-card summary:hover { background: var(--panel-2); }
.em-card summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -4px;
  transition: transform .15s;
}
.em-card[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.em-card[open] summary { border-bottom: 1px solid var(--line-soft); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

.em-img {
  width: 44px;
  height: 44px;
  flex: none;
  object-fit: contain;
}
.em-info { min-width: 0; flex: 1; }
.em-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.em-name a { color: inherit; text-decoration: none; }
.em-name a:hover { color: var(--accent); }
.em-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}
.em-cnt {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.em-year {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.em-meta .raritypill { font-size: 10px; padding: 2px 7px; }

.em-body {
  padding: 6px 14px 14px;
}

.em-year-row {
  position: relative;
  border-bottom: 1px solid var(--line-soft);
}
.em-year-row:last-child { border-bottom: 0; }
.em-year-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}
.em-year-head {
  flex: none;
  width: 52px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}
.em-year-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.em-year-pills .raritypill { font-size: 10px; padding: 2px 7px; }
.em-pill-wrap { display: inline-flex; }
.em-pill-wrap button { font-family: inherit; cursor: pointer; }

.em-expand {
  position: absolute;
  top: calc(100% + 4px);
  left: 62px;
  right: 14px;
  z-index: 21;
  display: none;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.em-expand::before {
  content: "";
  position: absolute;
  top: -13px;
  left: 0;
  right: 0;
  height: 13px;
}
.em-pill-wrap.open .em-expand,
.em-pill-wrap.hover .em-expand {
  display: block;
  animation: emDrop .18s ease;
}
.em-pill-wrap.hover .em-expand { z-index: 22; }

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

.em-circles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.em-expand .em-circles + .em-circles { margin-top: 8px; }
.em-circle {
  flex: none;
  width: 46px;
  height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--c, var(--line-strong));
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  line-height: 1.15;
}
.em-circle b {
  font-size: 10px;
  font-weight: 700;
}
.em-circle span {
  font-size: 12px;
  font-weight: 700;
  color: var(--c, var(--text));
}

.em-pager {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.em-pager .btn-ghost { text-decoration: none; }
.em-pager .btn-ghost[aria-disabled="true"] { opacity: .4; pointer-events: none; }

@media (max-width: 767px) {
  .em-grid { grid-template-columns: 1fr; }
  .em-card summary { padding: 10px 12px; }
  .em-body { padding: 2px 12px 12px; }
  .em-year-head { width: 44px; }
  .em-expand { left: 54px; right: 12px; }
  .em-circle { width: 40px; height: 40px; }
}
