.tag {
  --tag-wash: var(--tone-neutral-wash);
  --tag-glyph: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  height: 28px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: linear-gradient(#FFFFFF, #FFFFFF) padding-box, var(--tag-rim) border-box;
  box-shadow: var(--tag-shadow);
  color: var(--tone-neutral-ink);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.tag-plain {
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--ink-soft);
  font-size: 13px;
}

.tag[data-state] {
  padding-left: 7px;
  background: radial-gradient(76px circle at 15px 50%, var(--tag-wash), #FFFFFF) padding-box, var(--tag-rim) border-box;
}

.tag-plain[data-state] {
  padding-left: 0;
  border: 0;
  background: none;
}

.tag[data-state]::before {
  content: '';
  flex: none;
  width: 16px;
  height: 16px;
  background: var(--tag-glyph) center / contain no-repeat;
}

.tag:is([data-state="connected"], [data-state="complete"], [data-state="verified"]) {
  --tag-wash: var(--tone-good-wash);
  --tag-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2300D98B' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4.6 8.3 2.2 2.2 4.6-4.9'/%3E%3C/svg%3E");
}

.tag[data-state="active"] {
  --tag-wash: var(--tone-accent-wash);
  --tag-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236B4DFF' stroke-width='1.9' stroke-linecap='round'%3E%3Cpath d='M8 3.6a4.4 4.4 0 1 1-4.4 4.4'/%3E%3C/svg%3E");
}

.tag[data-state="active"]::before { animation: tag-spin 0.9s linear infinite; }

.tag[data-state="failed"] {
  --tag-wash: var(--tone-bad-wash);
  --tag-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23FF2D55' stroke-width='1.9' stroke-linecap='round'%3E%3Cpath d='m5.6 5.6 4.8 4.8m0-4.8-4.8 4.8'/%3E%3C/svg%3E");
}

.tag:is([data-state="debug"], [data-state="unverified"], [data-state="wait"]) {
  --tag-wash: var(--tone-wait-wash);
  --tag-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23FFA800' stroke-width='1.9' stroke-linecap='round'%3E%3Cpath d='M8 4.6v4.1'/%3E%3Ccircle cx='8' cy='11.3' r='0.35' fill='%23FFA800'/%3E%3C/svg%3E");
}

.tag:is([data-state="pending"], [data-state="off"], [data-state="sign_in"]) {
  --tag-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238A93A8' stroke-width='1.5' stroke-dasharray='2.1 2.1'%3E%3Ccircle cx='8' cy='8' r='5'/%3E%3C/svg%3E");
}

.tag:is([data-state="connected"], [data-state="complete"], [data-state="verified"], [data-state="failed"])::before { animation: tag-pop 0.45s cubic-bezier(0.22, 1, 0.36, 1); }

a.tag,
button.tag {
  font-family: var(--font-body);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.18s ease, transform 0.16s var(--ease-quint);
}

@media (hover: hover) {
  a.tag:hover,
  button.tag:hover {
    filter: brightness(0.97);
  }
}

@supports (transition-timing-function: linear(0, 1)) {
  a.tag,
  button.tag { transition: filter var(--motion-hover) ease, transform var(--motion-release) var(--ease-spring); }
  .tag:is([data-state="connected"], [data-state="complete"], [data-state="verified"], [data-state="failed"])::before { animation-timing-function: var(--ease-bounce); }
}

a.tag:active,
button.tag:active {
  filter: brightness(0.94);
  transform: scale(0.97);
  transition-duration: var(--motion-press);
  transition-timing-function: ease-out;
}

a.tag:focus-visible,
button.tag:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 3px;
}

.badge { display: flex; }

.badge > span {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  box-shadow: var(--shadow-dot);
  font-size: 14px;
  font-weight: 600;
}

.badge-provider { background: #FFFFFF; }

.badge-provider .icon {
  width: 16px;
  height: 16px;
}

.badge-person {
  background: var(--tint);
  color: var(--on-ink);
}

.badge-provider + .badge-person { margin-left: -10px; }

.badge-person:empty { display: none !important; }

@keyframes tag-spin {
  to { transform: rotate(1turn); }
}

@keyframes tag-pop {
  from { transform: scale(0.5); }
}

@media (prefers-reduced-motion: reduce) {
  .tag[data-state]::before { animation: none; }
  a.tag,
  button.tag { transition: none; }
  a.tag:active,
  button.tag:active { transform: none; }
}
